                  clean)
 
 ;          (println (apply str (repeat depth \ )) (count clean) (count dirtied) (count still-dirty))
-          (when (= (first (env/action-name (:action node))) 'nav)
-            (let [[_ dx dy] (env/action-name (:action node))]
-              (doseq [[ss sr] (stitch-effect-map clean state 0 #_ reward-to-state)]
-                (println ss sr clean new-results (env/action-name (:action node)))
-                (let [[sx sy] (map #(env/get-var state %) '[[atx] [aty]])]
-                  (when-not (= (- sr) (+ (util/abs (- sx dx)) (util/abs (- sy dy))))
-                     (println "ERROR" [sx sy] [dx dy] sr (:min-cycle-depth (:entry (meta ss))) reward-to-state) #_ (dr/debug-repl))))))
+;          (when (= (first (env/action-name (:action node))) 'nav)
+;            (let [[_ dx dy] (env/action-name (:action node))]
+;              (doseq [[ss sr] (stitch-effect-map clean state 0 #_ reward-to-state)]
+;                (println ss sr clean new-results (env/action-name (:action node)))
+;                (let [[sx sy] (map #(env/get-var state %) '[[atx] [aty]])]
+;                  (when-not (= (- sr) (+ (util/abs (- sx dx)) (util/abs (- sy dy))))
+;                     (println "ERROR" [sx sy] [dx dy] sr (:min-cycle-depth (:entry (meta ss))) reward-to-state) #_ (dr/debug-repl))))))
           
           (doseq [entry (concat good-roots (map #(:entry (meta (key %))) dirtied))] 
             (assert (util/xor (not (:sanode entry)) (:cutoff (meta entry))))

(defn expand-sa-node [node #^HashMap cache next-best state reward-to-state last-context
                      #^IdentityHashMap stack-node-depths depth]
  (assert (not (.containsKey stack-node-depths node)))
  (println (apply str (repeat depth \ )) "Entering " (env/action-name (:action node)) (map #(env/get-var state %) '[[atx] [aty]]) "at depth" depth ", " (count (first @(:result-vec-and-map-atom node))) ", " (cutoff (:queue node)) next-best last-context reward-to-state)
;  (println (apply str (repeat depth \ )) "States on queue are: " (util/map-map (fn [[k v]] [[(spos (:state k)) (map env/action-name (:remaining-actions k))] (- v)]) (into {} (filter #(< (second %) Double/POSITIVE_INFINITY) (queues/pq-peek-pairs (:queue node))))))  
  (.put stack-node-depths node depth)
  (let [good-queue (:queue node)

        init  (env/initial-state e)
        root  (get-sa-node cache init (hierarchy/TopLevelAction e [(hierarchy/initial-plan henv)]))]
    (loop [cutoff 0 last-cutoff 0]
;        (println "\ncutoff" cutoff "\n")
      (let [result (expand-sa-node root cache cutoff init 0.0 0 (IdentityHashMap.) 0)]
        (cond (not (empty? (:result-map result)))
                (let [[k v] (util/first-maximal-element val (:result-map result))]
