                                               (+ 1 depth)
                                               index parent morph)]
                           (if (empty? phrasal-children)
-                            (let [message (str "no phrasal children for parent: " (morph parent) "(rule=" (get-in parent [:rule]) ")" )]
+                            (let [message (str "no phrasal children for parent: " (morph parent) "(rule=" (get-in parent [:rule]) ") and spec: " (strip-refs spec))]
                               (log/debug message))
                             ;; else; there are phrasal-children, so attach them below parent:
                             (do

                     
                           ;; lazy-sequence of phrasal complements to pass one-by-one to the above (map)'s function.
                           (do
                             (log/debug (str "generating lexical complements with spec: " (strip-refs spec)))
                             (let [phrasal-complements (generate-all spec grammar lexicon cache morph)]
                               (if (lexemes-before-phrases)
                                 (lazy-cat shuffled-candidate-lexical-complements phrasal-complements)
                                 (do


        depth (if depth depth 0)        
        ;; TODO: unifyc is expensive: factor out into a let.
        debug (log/debug (str "looking for candidate head phrases with parent: " (:rule parent) " and spec: " (strip-refs spec)))
        candidate-heads (filter #(not (fail? %))
                                  (map (fn [rule]
                                         (do (log/debug (str "testing rule: " (:rule rule)))
                                             (log/debug (str "RULE:" (strip-refs rule)))
                                             (if (fail? rule)
                                               (throw (exception (str "THE RULE IS FAIL: " (strip-refs rule)))))
                                             (log/debug (str " result: " (strip-refs (unifyc spec rule))))
                                             (log/debug (if (fail? (unifyc spec rule))
                                                          (str "fail path: " (fail-path-between spec rule))
                                                          (str "rule: " (:rule rule) " successfully unified with spec: " (strip-refs spec))))
                                             (unifyc spec rule)))
                                       (if parent
                                         (let [hp (get-head-phrases-of parent index)]
                                           (log/debug (str "GETTING HEAD PHRASES: hp"))
                                           hp)
                                         (do
                                           (log/debug (str "NOT GETTING HEAD PHRASES: using grammar"))
                                           grammar))))

        debug (log/debug (str "done looking for candidate heads: "
                              (if (empty? candidate-heads)
                                "no candidate heads found."
                                (str "one or more candidate heads found; first: " (:rule (first candidate-heads))))))
        
        debug (if (not (empty? candidate-heads))
                (log/debug (str "candidate-heads: " (string/join "," (map #(get-in % [:rule])
                                                                            candidate-heads))))
                (log/debug (str "no candidate-heads for spec: " (strip-refs spec))))]
    ;; TODO: remove or parameterize this hard-coded value.
    (if (> depth 5)
      (throw (exception (str "DEPTH IS GREATER THAN 5; HOW DID YOU END UP IN THIS TERRIBLE SITUATION? LOOK AT THE STACK. I'M OUTTA HERE."))))

    (if (seq candidate-heads)
      (let [lexical ;; 1. generate list of all phrases where the head child of each parent is a lexeme.
            (mapcat (fn [parent]
                      (let [head-is-phrasal (get-in parent [:head :phrasal] false)
                            candidate-lexemes (if (not (= true head-is-phrasal))
                                                (get-lex parent :head index spec))]
                        (log/debug
                         (str "candidate head lexemes for parent phrase "
                              (get-in parent [:rule]) ": "
                              (string/join ","
