def _end_nodes(graph):
    """
    Returns all nodes with no predecessors. We filter the graph form these
    nodes.
    """
    end_nodes = []
    for node in graph:
        predecessor = graph.predecessors(node)
        if not predecessor:
            end_nodes.append(node)
    return end_nodes