                                              :package-id id}]}]
                                          (let [candidate-results
                                                (first-found
-                                                 (fn
-                                                   try-candidate
-                                                   [candidate]
-                                                   (resolve-deps
-                                                     repo
-                                                     present-packages
-                                                     (update-in found-packages [id]
-                                                                conj
-                                                                candidate)
-                                                     absent-specs
-                                                     (concat-reqs
-                                                       rclauses
-                                                       (map
-                                                         #(->DecoratedRequirement
-                                                            %
-                                                            candidate)
-                                                         (:requirements
-                                                           candidate)))
-                                                     (update-in
-                                                       present-packages
-                                                       [parent]
-                                                       conj candidate)))
+                                                (fn
+                                                  try-candidate
+                                                  [candidate]
+                                                  (resolve-deps
+                                                   repo
+                                                   present-packages
+                                                   (update-in found-packages
+                                                              [id]
+                                                              #(if (empty? %1)
+                                                                 (do [%2])
+                                                                 (conj %1 %2))
+                                                              candidate)
+                                                   absent-specs
+                                                   (concat-reqs
+                                                    rclauses
+                                                    (map
+                                                     #(->DecoratedRequirement
+                                                       %
+                                                       candidate)
+                                                     (:requirements
+                                                      candidate)))
+                                                   (update-in package-graph
+                                                              [parent]
+                                                              #(if (empty? %1)
+                                                                 (do [%2])
+                                                                 (conj %1 %2))
+                                                              candidate)))
                                                 successful?
                                                 filtered-query-results)]
                                            (or

                                        status)))]
                               (cond
                                 (not
                                   (nil? present-package))
                                 (resolve-deps
                                   repo
                                   present-packages
                                   found-packages
                                   absent-specs
                                   rclauses
                                   present-package
                                   (update-in package-graph
                                              [parent]
                                              conj
                                              present-package))
                                   (and (not (nil? present-id-packages))
                                        (not (= conflict-strat :inclusive)))
                                   [:unsuccessful
                                    {:problems
                                     [
                                      {:term clause
                                       :found-packages found-packages
                                       :present-packages present-packages
                                       :absent-specs absent-specs
                                       :reason :present-package-conflict
                                       :alternative alternative
                                       :package-id id}]}]
                                 (= status :absent)
                                 (resolve-deps
                                   repo
                                   present-packages
                                   found-packages
                                   (update-in
                                     absent-specs
                                     [id] conj spec)
                                   rclauses
                                   package-graph)
                                 (= status :present)
                                 (let [query-results (repo id)]
                                   (if (empty? query-results)

                                       children))
                     :visited (into visited-from-children children)}
                    children-results)))))]
    (let [{:keys [pkg-list visited]} (list-pkgs-rec #{} :root)]
      pkg-list)))


(defn resolve-dependencies
