   (defn go [path node] ;; TODO - optimize this by removing the recursion
     (cond
       (is-leaf? node) [(leaf-val node) path]
-      (is-node? node) (into
-                        (go (conj path 0) (lhs-node node))
-                        (go (conj path 1) (rhs-node node)))
+      (is-node? node) (mapcat #(go (conj path %) (child-at node %)) [0 1])
       ))
   (apply hash-map (go [] tree))) ;; TODO - Test check: verify that there are no code prefix of another
 

        ([] (xf))
        ([result] (xf result))
        ([result input]
          (let [next-branch (next-node @branch input)]
            (if (is-leaf? next-branch)
              (do
                (vreset! branch huffman-tree)

(def t (make-huffman-tree m))

(defn tests []
  (prn (encode-with t [:a :b :c :d :e]))
  (prn (second (encode [:a :b :c :d :e])))
  (prn (decode t [0 0 0 0 0 1 0 1 1 0 1 1]))
