   reversedDependencies = reverseGraph graph
   independent = []
 
+  for node in graph
+    node.origSet = cloneSet node.set
+
   moveToIndependent = (node) ->
     independent.push node
     delete dependencies[name] for name in node.names

    {missing, names, def, set} = where
    stillMissingNames = addAllTo dependencySet(),
      (name for name in (setToArray missing) when not inSet defined, name)
    if stillMissingNames.numDependencies == 0 and set.numDependencies == 0
      hoisted.push def
      addAllTo hoistedNames, names
    else

    for child in reversedDependencies[finishedParent.names[0]] or []
      removeDependency child.set, name for name in finishedParent.names
      moveToIndependent child if child.set.numDependencies is 0

  for node in sorted
    node.set = node.origSet

  for parent of dependencies
    throw new Error "Cyclic definitions between #{(name for name of dependencies).join ','}"
