def iter_parents(p): if not p.difficult_parent_child: for pp in p.known_parents: yield pp return for e in p.edges: o = e.other(p) if e.definitive_child and child_parent_direction(o, p): yield o
def iter_children(p): if not p.difficult_parent_child: for c in p.children: yield c return for e in p.edges: o = e.other(p) if e.definitive_child and child_parent_direction(p, o): yield o