(self, other)
Find the common ancestor between this history node and 'other'.

        :param other:    the PathHistory to find a common ancestor with.
        :return:        the common ancestor SimStateHistory, or None if there isn't one
Find the common ancestor between this history node and 'other'.
Find the common ancestor between this history node and other .
def closest_common_ancestor(self, other):
        """
        Find the common ancestor between this history node and 'other'.

        :param other:    the PathHistory to find a common ancestor with.
        :return:        the common ancestor SimStateHistory, or None if there isn't one
        """
        our_history_iter = reversed(HistoryIter(self))
        their_history_iter = reversed(HistoryIter(other))
        sofar = set()

        while True:
            our_done = False
            their_done = False

            try:
                our_next = next(our_history_iter)
                if our_next in sofar:
                    # we found it!
                    return our_next
                sofar.add(our_next)
            except StopIteration:
                # we ran out of items during iteration
                our_done = True

            try:
                their_next = next(their_history_iter)
                if their_next in sofar:
                    # we found it!
                    return their_next
                sofar.add(their_next)
            except StopIteration:
                # we ran out of items during iteration
                their_done = True

            # if we ran out of both lists, there's no common ancestor
            if our_done and their_done:
                return None
def closest_common_ancestor ( self , other ) : our_history_iter = reversed ( HistoryIter ( self ) ) their_history_iter = reversed ( HistoryIter ( other ) ) sofar = set ( ) while True : our_done = False their_done = False try : our_next = next ( our_history_iter ) if our_next in sofar : # we found it! return our_next sofar . add ( our_next ) except StopIteration : # we ran out of items during iteration our_done = True try : their_next = next ( their_history_iter ) if their_next in sofar : # we found it! return their_next sofar . add ( their_next ) except StopIteration : # we ran out of items during iteration their_done = True # if we ran out of both lists, there's no common ancestor if our_done and their_done : return None