code: def _get_dependency_order(g, node_list):
      
      access_ = accessibility(g)
      deps = dict((k, set(v) - set([k])) for k, v in access_.iteritems())
      nodes = node_list + list(set(g.nodes()) - set(node_list))
      ordered_nodes = []
  
      while nodes:
          n_ = nodes[0]
          n_deps = deps.get(n_)
          if (n_ in ordered_nodes) or (n_deps is None):
              nodes = nodes[1:]
              continue
  
          moved = False
          for i, n in enumerate(nodes[1:]):
              if n in n_deps:
                  nodes = [nodes[i + 1]] + nodes[:i + 1] + nodes[i + 2:]
                  moved = True
                  break
  
          if not moved:
              ordered_nodes.append(n_)
              nodes = nodes[1:]
  
      return ordered_nodes
docs: Return list of nodes as close as possible to the ordering in node_list,
      but with child nodes earlier in the list than parents.