     independent.push node
     delete dependencies[name] for name in node.names
 
-  for parent in graph when parent.set.numDependencies is 0
+  for parent in graph when parent.set.size is 0
     moveToIndependent parent
 
   sorted = []

        definingScope = lookupIdentifier token, node
        parent = lookupByName[token]
        if parent
          addDependency child.set, name for name in parent.names unless child is parent
          addDependency deps, parent
        else if isReference(node) and !lookupIdentifier token, node
          addDependency child.missing, node.token
  [graph, lookupByName]

lookupTableForGraph = (graph) ->

#   Map (name -> GraphElement)
constructDependencyGraph = (wheres) ->
  lookupByName = {}
  deps = newSet()
  # find all defined names
  graph = for [pattern, def], i in wheres
    def: [pattern, def]
    set: newSet()
    names: findNames pattern
    missing: newSet()

  lookupByName = lookupTableForGraph graph

