@staticmethod
def _walk_generic_dominator(node, gen_dominators, succ_cb):
    """Generic algorithm to return an iterator of the ordered list of
        @node's dominators/post_dominator.

        The function doesn't return the self reference in dominators.
        @node: The start node
        @gen_dominators: The dictionary containing at least node's
        dominators/post_dominators
        @succ_cb: return predecessors/successors of a node

        """
    done = set()
    if node not in gen_dominators:
        return
    node_gen_dominators = set(gen_dominators[node])
    todo = set([node])
    node_gen_dominators.remove(node)
    while node_gen_dominators:
        new_node = None
        while todo:
            node = todo.pop()
            if node in done:
                continue
            if node in node_gen_dominators:
                new_node = node
                break
            done.add(node)
            for pred in succ_cb(node):
                todo.add(pred)
        assert new_node is not None
        yield new_node
        node_gen_dominators.remove(new_node)
        todo = set([new_node])
