'Return a topologically sorted iterator over a dependency graph.
This is a destructive operation for the graph.'

@staticmethod
def toposort(graph):

    for iteration in six.moves.xrange(len(graph)):
        for (key, node) in six.iteritems(graph):
            if (not node):
                (yield key)
                del graph[key]
                break
        else:
            raise CircularDependencyException(cycle=six.text_type(graph))
