def _keyfunc(graph, node_idx):
    """
    Reduce a molecule node to a tuple of chain, resid, and resname.
    """
    return graph.nodes[node_idx]['chain'], graph.nodes[node_idx]['resid'
        ], graph.nodes[node_idx]['resname']
