def _aggregate(nodes, fingerprint_fn):
  """Returns list of nodes aggregated by target string."""
  fingerprints_to_nodes = collections.OrderedDict()
  aggregated_nodes = []
  for node in nodes:
    fingerprint = fingerprint_fn(node)
    if fingerprint not in fingerprints_to_nodes:
      fingerprints_to_nodes[fingerprint] = []
    fingerprints_to_nodes[fingerprint].append(node)
  for _, nodes in fingerprints_to_nodes.items():
    if len(nodes) > 1:
      aggregated_node = AggregationNode(nodes)
      aggregated_nodes.append(aggregated_node)
    else:
      aggregated_nodes.append(nodes[0])
  return aggregated_nodes
Returns list of nodes aggregated by target string.
language/compgen/csl/model/data/parsing_utils.py