Format type dependencies information to use if for reordering.

def prepare(self, node):
        """ Format type dependencies information to use if for reordering. """
        super(Reorder, self).prepare(node)
        candidates = self.type_dependencies.successors(
            TypeDependencies.NoDeps)
        # We first select function which may have a result without calling any
        # others functions.
        # Then we check if no loops type dependencies exists. If it exists, we
        # can safely remove the dependency as it could be compute without this
        # information.
        # As we can compute type for this function, successors can potentially
        # be computed
        # FIXME: This is false in some cases
        #
        # def bar(i):
        #   if i > 0:
        #     return foo(i)
        #   else:
        #     return []
        #
        # def foo(i):
        #   return [len(bar(i-1)) + len(bar(i - 2))]
        #
        # If we check for function without deps first, we will pick bar and say
        # it returns empty list
        while candidates:
            new_candidates = list()
            for n in candidates:
                # remove edges that imply a circular dependency
                for p in list(self.type_dependencies.predecessors(n)):
                    if nx.has_path(self.type_dependencies, n, p):
                        self.type_dependencies.remove_edge(p, n)
                if n not in self.type_dependencies.successors(n):
                    new_candidates.extend(self.type_dependencies.successors(n))
            candidates = new_candidates