                              (let [debug (log/debug (str "adding complement to: ["
                                                          (get-in bolt [:rule]) " "
                                                          (morph bolt) "]: trying lexical complement:" (morph complement)))
+                                   debug (if (= "" (morph complement))
+                                           (log/error (str "WHY IS IT EMPTY: " complement)))
                                    result
                                    (unify (copy bolt)
                                           (path-to-map path

        from-bolt bolt ;; so we can show what (add-complement) did to the input bolt, for logging.
        bolt-spec (get-in bolt path :no-path)
        spec (unifyc spec bolt-spec)]
    (log/trace (str "add-complement at path: " path " to bolt with bolt:["
                    (if (map? bolt) (get-in bolt [:rule]))
                    " '" (morph bolt) "'"
                    "]"))
    (log/trace (str "add-complement to bolt with path:" path))

    (if (not (= bolt-spec :no-path)) ;; check if this bolt has this path in it.
      (let [immediate-parent (get-in bolt (butlast path))

head of its parent. generate (above) 'decorates' each returned lightning bolt
of this function with complements."

  (if (empty? grammar)
    (do
      (log/error (str "grammar is empty."))
      (exception (str "grammar is empty."))))
  
  (if (and (not (= :fail spec))
           (not (empty? (strip-refs spec))))
    (log/debug (str "lighting-bolt@" depth " spec: " (strip-refs spec) "; parent: " (if parent
                                                                                      (:rule parent)))))
  (if (not parent)
    (log/debug (str "no parent for lightning-bolt@" depth " with spec: " (strip-refs spec))))
  (let [maxdepth 3 ;; maximum depth of a lightning bolt: H1 -> H2 -> H3 where H3 must be a lexeme, not a phrase.
        debug (log/debug (str "lightning-bolt@" depth " grammar:" (string/join ", " (map #(get-in % [:rule]) grammar))))

        depth (if depth depth 0)        
        ;; TODO: unifyc is expensive: factor out into a let.
        debug (log/debug (str "looking for candidate parents with parent: " (:rule parent) " and spec: " (strip-refs spec)))
        candidate-parents (filter #(not (fail? %))
                                  (map (fn [rule]
                                         (do (log/debug (str "testing rule: " (:rule rule)))
                                             (unifyc spec rule)))
                                       (if parent (get-head-phrases-of parent index)
                                           grammar)))

        debug (log/debug (str "done looking for candidate parents: "
                              (if (empty? candidate-parents)
                                "no candidate parents found."
                                (str "one or more candidate parents found; first: " (:rule (first candidate-parents))))))
        
        debug (if (not (empty? candidate-parents))
                (log/debug (str "candidate-parents: " (string/join "," (map #(get-in % [:rule])
                                                                            candidate-parents))))
                (log/debug (str "no candidate-parents 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."))))
