def get_merged_node(source, rules):
  """Return node corresponding to all parses."""
  tokens = source.split(" ")

  def node_fn(span_begin, span_end, rule, children):
    # Target string is ignored for this case.
    target_string = None
    return RuleApplicationNode(rule, children, span_begin, span_end,
                               target_string)

  def postprocess_fn(nodes):
    if len(nodes) > 1:
      return [AggregationNode(nodes)]
    else:
      return nodes

  nodes = qcfg_parser.parse(
      tokens, rules, node_fn=node_fn, postprocess_cell_fn=postprocess_fn)
  if len(nodes) != 1:
    raise ValueError("example `%s` len(nodes) != 1: %s" % (source, nodes))

  return nodes[0]
Return node corresponding to all parses.
language/compgen/nqg/model/parser/data/parsing_utils.py