             (queues/g-pq-replace! good-queue entry 
               (- 0 (:reward-to-state entry) (if-let [n  (:sanode entry)] (cutoff (:queue n)) 0))))
           (.remove stack-node-depths node) ;; TODO: catchup!! 
+          (println "Returning from" (env/action-name (:action node)) "With cutoff" cut (cutoff good-queue) "and cdm" cutoff-depth-map "and states" (count new-results) (count catchup) "-" (count clean) (count dirtied) (count still-dirty) "and good roots" (count good-roots) (map :reward-to-state good-roots))
           (PartialResult (stitch-effect-map 
                            (into {} (map (fn [[s r]] [(vary-meta s assoc :cycle-depth 
                                                         (final-cycle-depth r (or (:cycle-depth (:entry (meta s))) 

  (let [[_ reward-cycle-depth] (first (subseq cutoff-depth-map > reward))]
    (min cycle-depth reward-cycle-depth)))

(defn extend-cutoff-depth-map [cdm cutoff depth node-depth]
;  (println cdm cutoff depth)
  (let [[g-cutoff g-depth] (first (subseq cdm >= cutoff))]
    (if (< depth (min node-depth  g-depth)) (assoc cdm cutoff depth) cdm)))

;; May return states better than next-best, but these will be held at the parent.
(defn expand-sa-node [node #^HashMap cache next-best state reward-to-state last-cutoff
                      #^IdentityHashMap stack-node-depths depth]
  (assert (not (.containsKey stack-node-depths node)))
  (println "Entering " (env/action-name (:action node)) "at depth" depth)
  (.put stack-node-depths node depth)
  (let [good-queue (:queue node)
        bad-queue  (queues/make-graph-stack-pq)
