                                                                     (get-in bolt (concat path
                                                                                          [:synsem :sem :pred]))))))
                                      (str "'" (morph %) "':"
-                                          (fail-path-between (strip-refs %)
-                                                             (strip-refs (get-in bolt path)))))
+                                          (fail-path (strip-refs %)
+                                                     (strip-refs (get-in bolt path)))))
                                   (take log-limit complement-candidate-lexemes)))
                 
                 (if (< 0 (- (count complement-candidate-lexemes) log-limit))

                                                 (get-in bolt (concat path [:phrasal]))))
                                       (if cached cached (flatten (vals lexicon))))
        complement-pre-check (fn [child parent path-to-child]
                               (let [child-in-bolt (get-in bolt path-to-child)]
                                 (and (not (fail?
                                            (unifyc (get-in child [:synsem] :top)
                                                    (get-in child-in-bolt [:synsem] :top)))))))
        filtered-lexical-complements (filter (fn [lexeme]
                                               (complement-pre-check lexeme bolt path))
                                             complement-candidate-lexemes)]
    (filter (fn [complement]
              (if (fail? complement)
                (do

  (let [total-depth (if total-depth total-depth 0)
        add-complements-to-bolts
        (fn [bolts path]
          (log/debug (str "generate-all: "
                          "add-complements-to-bolts@" path ":#bolts(" (count bolts) "):"
                          (string/join ","
                                       (map (fn [bolt]
                                              (show-bolt bolt path morph))
                                            bolts))))
          (mapcat
           #(if (not (= :none (get-in % path :none)))
              (add-complement % path :top grammar lexicon index morph 0 (+ total-depth (count path)))
              [%])
           bolts))

        expressions
        (-> (lightning-bolt (lazy-shuffle grammar)
                            lexicon
                            spec 0 index morph total-depth)
            ;; TODO: allow more than a fixed maximum depth of generation (here, 4 levels from top of tree).
            (add-complements-to-bolts [:head :head :head :comp] )
            (add-complements-to-bolts [:head :head :comp])
            (add-complements-to-bolts [:head :comp])
            (add-complements-to-bolts [:comp]))]

    (if (not (empty? expressions))
      (log/info (str "generate-all: first expression generated for spec:" (strip-refs spec) " ):"
                     "'" (morph (first expressions)) "'"))
      (log/debug (str "generate-all: no expressions could be generated for spec:" (strip-refs expressions))))
    expressions))

(defn lightning-bolt [grammar lexicon spec depth index morph total-depth]
  "Returns a lazy-sequence of all possible trees given a spec, where
