                                         
 ;; during generation, will not decend deeper than this when creating a tree:
 ;; TODO: should also be possible to override per-language.
-(def ^:const max-total-depth 6)
+(def ^:const max-total-depth 2)
 
 ;; TODO support setting max-generated-complements to :unlimited
 (def ^:const max-generated-complements 20000)

                  (or (:lexicon (:generate model)) (:lexicon model))))))
    []))

(declare comp-path-to-bolts)
(declare create-mapping)

(declare nugents)

;;(def foo (map #(println (fo %)) (take 10000 (nugents med spec))))

(declare add-bolt-at)
(declare do-assoc)

(defn filter-by [bolt-and-comps]
  (not (some empty? (vals bolt-and-comps))))

(declare bolts-with-comps)

(defn nugents [model spec & [max-depth]]
  (log/debug (str "nugents:" (strip-refs spec)))
  (let [max-depth (or max-depth babel.generate/max-total-depth)
        bolts-and-comps (filter #(not (some empty? (vals %)))
                                (bolts-with-comps spec model 0 max-depth))
        all-of-them
        (mapcat (fn [each-bolt-and-comps]
                  (let [trellis (apply combo/cartesian-product (vals each-bolt-and-comps))]
                    (map (fn [each-path-through-trellis]
                           (zipmap (keys each-bolt-and-comps)
                                   each-path-through-trellis))
                         trellis)))
                bolts-and-comps)]
    (filter not-fail?
            (map (fn [bolt-and-comps]
                   (log/debug (str "bolt-and-comps: " ((:morph-ps model) (get bolt-and-comps []))))
                   (do-defaults
                    (do-assocs (get bolt-and-comps [])
                               (dissoc bolt-and-comps []))
                    model))
                 all-of-them))))

;; TODO: use recur or reduce
(defn do-assocs [accum paths-to-vals-at-path]

                   (flatten
                    (add-comps bolt-at model
                               comp-paths
                               (mapfn #(comp-path-to-complements bolt-at % model (+ 1 depth) max-depth)
                                      comp-paths)
                               (+ 1 depth) max-depth top-bolt truncate? take-n)))))))
(defn generate
