def iter_from_root_to_leaves(graph):
    """
    Generator function to iterate through all nodes of a graph, 
    from the root to its leaves, prioritizing each next node on the same
    level by the order in which it was added.
    @return: An iterator.
    """
    current = graph.ROOT
    visited = []
    stack = []
    while True:
        if current not in visited:
            visited.append(current)
            yield current
            children = graph.get_supported_by(current)
            stack.append(iter(children))
        try:
            current = stack[-1].next()
        except StopIteration:
            stack.pop()
        except IndexError:
            break
