       ""
   call.tea = new Constrained (join doneConds.constraints, doneResults.constraints),
       doneResults.itemType
-  branches = for res in doneResults.compiled
-    [(jsReturn res)]
   assignCompile ctx, call,
     (iife [(jsConditional (zip doneConds.compiled[0...branches.length], branches),
         "throw new Error('cond failed to match#{errorMessage}');")])
 
+findDefinitionsIncludingDeps = (ctx, names) ->
+  findDefinitions ctx, setToArray (findDeps ctx) names
+
+findDefinitions = (ctx, names) ->
+  auxiliaries = ctx.auxiliaries()
+  concat (for name in names
+    (lookupInMap auxiliaries, name)?.definition or [])
+
+findDeps = (ctx) -> (names) ->
+  auxiliaries = ctx.auxiliaries()
+  arrayToSet reverse join names, auxiliaryDependencies auxiliaries, names
+
+auxiliaryDependencies = (graph, names) ->
+  concat (for name in names
+    join (deps = ((lookupInMap graph, name)?.deps or [])),
+      auxiliaryDependencies graph, deps)
 
 ms['`'] = ms_quote = (ctx, call) ->
   [res] = _arguments call

          (irFunction
            name: (ctx.definitionName() if ctx.isAtSimpleDefinition())
            params: paramNames
            body: (join compiledWheres, [(jsReturn compiledBody)]))
            # (jsCall "λ#{paramNames.length}", [
            #   (jsFunction
            #     name: (ctx.definitionName() if ctx.isAtSimpleDefinition())

        # If can't compile, defer further
        ctx.addDeferredDefinition deferred
        deferredCount++
  compiledPairs

deferDeferred = (ctx) ->
  # defer completely current scope
