'Find the "most mergeable" set of states from those provided.
:param states: a list of states
:returns: a tuple of: (a list of states to merge, those states\' common history, a list of states to not merge yet)'

def most_mergeable(self, states):

    histories = set((self.get_ref(s.history) for s in states))
    for n in networkx.algorithms.dfs_postorder_nodes(self._graph):
        intersection = histories.intersection(self.all_successors(n))
        if (len(intersection) > 1):
            return ([s for s in states if (self.get_ref(s.history) in intersection)], n(), [s for s in states if (self.get_ref(s.history) not in intersection)])
    return (set(), None, states)
