def _get_compounds_inner(node_1, node_1_idx, node_2, node_2_idx, node_3):
  """Recursively generates compounds.

  Each iteration adds the compounds for these paths if inputs are not None:
  - node_2 -> node_1
  - node_3 -> node_2 -> node_1

  Args:
    node_1: Node.
    node_1_idx: Index of node_1 in node_2's children list.
    node_2: Node.
    node_2_idx: Index of node_2 in node_3's children list.
    node_3: Node

  Returns:
    Counter of compounds.
  """
  compounds = collections.Counter()

  if node_2:
    compound_2 = _get_2_compound_string(node_1, node_1_idx, node_2)
    compounds[compound_2] += 1

  if node_3:
    compound_3 = _get_3_compound_string(node_1, node_1_idx, node_2, node_2_idx,
                                        node_3)
    compounds[compound_3] += 1

  for child_idx, child in enumerate(node_1.children):
    compounds.update(
        _get_compounds_inner(child, child_idx, node_1, node_1_idx, node_2))
  return compounds
Recursively generates compounds.

  Each iteration adds the compounds for these paths if inputs are not None:
  - node_2 -> node_1
  - node_3 -> node_2 -> node_1

  Args:
    node_1: Node.
    node_1_idx: Index of node_1 in node_2's children list.
    node_2: Node.
    node_2_idx: Index of node_2 in node_3's children list.
    node_3: Node

  Returns:
    Counter of compounds.
  
language/compgen/nqg/tasks/spider/tmcd_utils.py