'Recursive helper for eq_dag and ne_dag.  Does the actual DAG
traversal.'

def _eq_dag(self, other, vs, vo, deptypes):

    vs.add(id(self))
    vo.add(id(other))
    if self.ne_node(other):
        return False
    if (len(self._dependencies) != len(other._dependencies)):
        return False
    ssorted = [self._dependencies[name] for name in sorted(self._dependencies)]
    osorted = [other._dependencies[name] for name in sorted(other._dependencies)]
    for (s_dspec, o_dspec) in zip(ssorted, osorted):
        if (deptypes and (s_dspec.deptypes != o_dspec.deptypes)):
            return False
        (s, o) = (s_dspec.spec, o_dspec.spec)
        visited_s = (id(s) in vs)
        visited_o = (id(o) in vo)
        if (visited_s != visited_o):
            return False
        if (visited_s or visited_o):
            continue
        if (not s._eq_dag(o, vs, vo, deptypes)):
            return False
    return True
