 
 (defn insert-tag-into-children-tag-summary
   [tag ch-tags]
-  {:paths (->> ch-tags
+  {:paths (-<> ch-tags
                :paths
-               (mapv #(into [tag] %)))
+               not-empty
+               (or [[]])
+               (mapv #(into [tag] %)
+                     <>))
    :set (-> ch-tags
             :set
+            (or #{})
             (conj tag))})
 
 (defn get-children-tag-summary*


#_ (get-tags' {:id 1} {:a #(-> % :id #{1}) :b #(-> % :id #{1})})

(defn merge-children-tag-summary
  [& rest]
  {:paths (->> rest

                                                 (apply merge-children-tag-summary))
                                            (merge-children-tag-summary)))))

(defn get-children-tag-summary ;; memoize?
  [zipr pred-map]
  (->> zipr
       children-zips
       (map #(get-children-tag-summary* %
                                        pred-map))
       (apply merge-children-tag-summary)))

#_ (ppcp (get-children-tag-summary z1
                                   {:a #(-> % :id #{1 2 3 4}) :even #(-> (do %)
                                                                         :id
                                                                         even?)}))

(defn get-parents-tag-summary ;; memoize?
  [zipr pred-map]
  (if-let [p (z/up zipr)]
    (insert-tags-into-parent-tag-summary (get-tags' (z/node p)
                                                    pred-map)
                                         (get-parents-tag-summary (z/up p)
                                                                  pred-map))
    (insert-tags-into-parent-tag-summary))) ;; tail recursion possible?

(defn tag*
  [zipr pred-map]
  (z/edit zipr (fn [z] (with-meta z
                         {::? {:tags  (get-tags' (z/node zipr) pred-map)
                               :parents (get-parents-tag-summary zipr pred-map)
                               :children (get-children-tag-summary zipr
                                                                   pred-map)}}))))

(defn tag
  [zipr pred-map]
  (binding [*get-tags-mz* (memoize get-tags)]
    (loop [z (-> zipr
                 (tag* pred-map))]
      (let [zn (z/next z)]
        (if-not (z/end? zn)
          (recur (tag* zn pred-map))
          (z/root z))))))

#_ (do
     (def tree2 (tag z1
                     {:a #(-> % :id #{1 2 3 4}) :even #(-<> (do %)
                                                            :id
                                                            even?)}))
     (ppcp tree2)
     (println)
     (-> tree2
         meta
         ppcp))

#_ (do

