                          (util/filter-map #(<= (val %) last-cutoff)  @(:result-map-atom node)))]
      (if (< (cutoff node) next-best)
          (PartialResult (stitch-results new-results state reward-to-state) (cutoff node))   
-       (let [[entry neg-reward] (queues/pq-remove-min-with-cost! (queue node))
+       (let [[entry neg-reward] (queues/pq-remove-min-with-cost! (:queue node))
              b-s (:state entry), b-rts (:reward-to-state entry), b-ra (:remaining-actions entry), b-sa (:sanode entry)
              rec-next-best (max next-best (cutoff node))]
            (if (empty? b-ra)

                        [(SANodeEntry s (when (seq ref) (get-sa-node cache s (first ref))) 0.0 ref) 0.0])))))))



(defn stitch-results [effect-map state reward-to-state]
  (util/map-map 

                 (recur (assoc-safe new-results >= eff b-rts)))
             (let [rec (expand-sa-node b-sa cache (- rec-next-best b-rts) b-s b-rts (- 0 neg-reward b-rts))]
               (when (> (:cutoff rec) Double/NEGATIVE_INFINITY) 
                 (queues/pq-replace! (:queue node) entry (- 0 b-rts (:cutoff rec))))
               (doseq [[ss sr] (:result-map rec)]
                 (queues/pq-add! (:queue node)
                   (SeqNodeEntry ss (when (next b-ra) (get-sa-node cache ss (second b-ra))) sr (next b-ra))
                   (- sr)))
               (recur new-results)))))))
