         run-next
         (assoc ::run-next run-next)))))
 
-(defn extend-node-run-next [{::keys [index-syms] :as out} {::keys [run-next run-next-stack] :as env}]
+(defn extend-resolver-run-next
+  "Extend "
+  [{::keys [index-syms] :as out}
+   {::keys [run-next run-next-trail] :as env}]
   (if run-next
     (if-let [node-ids (seq (get index-syms (pc-sym env)))]
       (reduce
         (fn [out node-id]
-          (if (contains? run-next-stack node-id)
+          (if (contains? run-next-trail node-id)
             out
             (let [node      (get-in out [::nodes node-id])
                   new-out   (compute-root-and (assoc out ::root (::run-next node)) env {::node-id run-next})

            (dissoc out ::root)
            (-> env
                (dissoc pc-attr)
                (update ::run-next-stack p.misc/sconj (::root out))
                (update ::attr-deps-stack p.misc/sconj (pc-attr env))
                (assoc ast-node (eql/query->ast (vec missing))
                  ::run-next (::root out)
                  ::provides (::provides root-node))))]

(defn merge-node-provides [out target-node-id {::keys [provides]}]
  (update-in out [::nodes target-node-id ::provides] merge-io provides))

(defn collapse-dynamic-nodes
  "Collapses new-node into collapse-node-id. This function is intended to be used
  to merge two dynamic nodes. When this happens, the requires and provides of both
  nodes will get merged, new-node is gonna be removed from the graph and new provides
  get propagated back."
  [{::keys [root] :as out}
   env
   new-node
   collapse-node-id]
  (-> out
      (merge-node-requires collapse-node-id new-node)
      (merge-node-provides collapse-node-id new-node)
      (merge-node-requires root new-node)
      (remove-node new-node)
      (propagate-provides {::node-id collapse-node-id})
      (simplify-branch env)))

(defn add-branch-node
  "Given a branch node is the root, this function will add the new node as part
  of that branch node. If the node is a repeating dynamic node it will cause the new node
  to be collapsed into the already existent dynamic node."
  [{::keys [root] :as out}
   {::keys [branch-type] :as env}
   {::keys [node-id]}]
  (let [node (get-node out node-id)]
    (if-let [collapse-node-id (find-dynamic-node-to-merge out env node)]
      (collapse-dynamic-nodes out env node collapse-node-id)
      (-> out
          (update-in [::nodes root branch-type] conj node-id)
          (merge-node-provides root node)
