  (fn [channels [words channel]]    
    (add-words channels words channel)))
 
+
+(defn tree->words [tree]
+  (let [flattened (tree-seq map? #(:children %) tree)]
+    (reduce #(conj %1 %2) [] flattened)))
+
+
+;; TODO get the tree as clojure map from somewhere
+(register-handler
+ :tree-add
+ channel-mw
+ (fn [channels [tree channel]]
+   (let [words (tree->words tree)]   
+     (add-words channels (tree->words tree) channel))))
+
+

              (assoc % :items (delete (:items %) item)) 
              %) channels))))


(register-handler 
 :channel-set-mix

(defn delete [vect item]
  (vec (remove (fn [word] (= word item)) vect)))

(defn update-item [vect item text]
  (let [i (.indexOf (to-array vect) item)]
    (if (>= i 0)
      (assoc vect i text)
      vect)))

(register-handler 
 :delete
 channel-mw
