                      ;; and candidate head must be copied.
                      (log/warn (str "tried: " (count subset) " lexical candidates with spec:"
                                     (strip-refs spec) " and all of them failed as heads of parent:" (get-in parent [:rule]))))
-                   (log/trace (str "returning bolts: count: " (count result)))
                    result)))
              (filter #(= false
                          (get-in % [:head :phrasal] false))

               (let [lexicon (or (:lexicon (:generate language-model)) (:lexicon language-model))
                     subset (if-let [index-fn (:index-fn language-model)]
                              (index-fn (get-in parent [:head] :top))
                              (do (log/warn (str "lightning-bolts: no index-fn for model:" (:name language-model) ": using entire lexicon."))
                                  (flatten (vals lexicon))))]
                 (if (not (empty? subset))
                   (log/debug (str "lightning-bolts: " (get-in parent [:rule])
                                   " : subset of candidate heads: "
                                   (count subset) " with spec: " (strip-refs spec)))
                   (log/debug (str "index returned a null set for spec:" (strip-refs spec))))
                 (log/trace (str "lightning-bolts: " (get-in parent [:rule])
                                 " : head lexeme candidates: "
                                 (string/join ","
                                              (map #((:morph language-model) %)
                                                   subset))))
                                                     
                 (log/trace (str "trying overh with parent: " (:rule parent) " and head constraints: " (get-in parent [:head])))
                 (let [result (over/overh parent (shuffle subset))]
                   (when (not (empty? subset))
                     (log/trace (str "lightning-bolts:  surviving candidate heads: " (count subset) " -(unify)-> " (count result))))

                   (log/trace (str "lightning-bolts: surviving results: " 
                                   (string/join ","
                                                (map #((:morph language-model) %)
                                                     result))))

                   (if (and (not (empty? subset)) (empty? result)
                            (> (count subset)
                               50))

  [language-model spec depth total-depth
                       & {:keys [max-total-depth]
                          :or {max-total-depth max-total-depth}}]
  (let [grammar (:grammar language-model)
        depth (if depth depth 0)
        ;; this is the relative depth; that is, the depth from the top of the current lightning bolt.
