 (defn find-in [xs n]
   (.indexOf xs n))
 
+(defrecord Node [triple element sub-counter children])
+
+(defn count-elements
+  [{:keys [sub-counter element]}]
+  (if element
+    (inc sub-counter)
+    sub-counter))
+
+(defn count-children
+  [children]
+  (reduce + (map count-elements children)))
+
 (defn node-zip
   [root]
   (z/zipper
-    (fn [_] true)
-    (fn [n] (if (vector? n)
-              (seq n)
-              (:children n)))
-    (fn [n c] nil) ;do not use any editing on the tree
+    (fn [node] (:children node))
+    (fn [node] (seq (:children node)))
+    (fn [{:keys [triple element]} children]
+      (->Node triple
+              element
+              (count-children children)
+              (sorted :triple children)))
     root))
-
-(defrecord Node [triple element sub-counter children])
 
 (defn node
   [[triple & xs] element]

  (let [paths (indexes node limb)]
    (if (some nil? paths)
      nil
      (loop [paths paths,
             node node,
             acc (if (:element node) 1 0)]
        (let [head (first paths), tail (next paths)
              {:keys [children]} node]
          (if head
            (recur tail
                   (nth children head)
                   (+ acc (left-to-right head node)))
            (dec acc))))))) ;zero-based index

(defn indexes
  "returns a vector of numbers for each level that the index of a limb is

                (= (count children) 0))
          (conj path index)
          (recur (conj path index)
                 (nth children index)
                 (first (:children limb))))))))

(defn crawl-to
  "returns a zipper with it's location where the index in a node"
