         (recur (z/up zip) child)
         build))))
 
-(defn node
-  [[triple & xs] element]
-  (if (= (count xs) 0)
-    (Node. triple element 0 [])
-    (Node. triple nil 1 [(node xs element)])))
+(defn fetch [node index]
+  "takes a node and an index and returns a recreation of the node at that index
+  as a limb"
+  (-> node
+      (crawl-to index)
+      (crawl-out)))
+

               (z/right branch)
               (+ sub-counter acc*))))))

(defn right-to-left
  [position {:keys [children] :as tree}]
  (loop [pos 0
         branch (-> tree node-zip z/down z/rightmost)
         acc 0]
    (let [{:keys [sub-counter element]} (z/node branch)]
      (if (= (+ pos (inc position)) (count children))
        (- (:sub-counter tree) acc)
        (recur (inc position)
               (z/left branch)
               (+ sub-counter (if element (inc acc) acc)))))))

(defn strat
  [position acc sub-count]
  (if (< (- position acc) (/ sub-count 2))
    left-to-right right-to-left))

(defn index-of
  [this node]
  (if-let [full-path (indexes this node)]
      (loop [path full-path,
             tree this,
             acc (if (:element tree) 1 0)]
        (let [head (first path), tail (next path)
              {:keys [sub-counter children]} tree]
          (if head
            (recur tail
                   (nth children head)
                   (+ acc
                      ;((strat head acc sub-counter)head tree)
                      (left-to-right head tree)))
            (dec acc))))
      nil))

(defn indexes
  [this node]
  (loop [xs [], tree this, path node]
    (let [{:keys [children]} tree
          index (find-in (map :triple children) (:triple path))]
      ;does the tree contain the path
      (if (or (< index 0)
              (and (= index 0) (= (count children) 0)))
        nil
        ;does the path have more children
        (if (or (= (count (:children path)) 0)
                (= (count children) 0))
          (conj xs index)
          (recur (conj xs index)
                 (get-in tree [:children index])
                 (get-in path [:children 0])))))))

(defn crawl-to
  "returns a zipper at the nth element"
  [node index]
  (loop [zip (node-zip node)
         to-go index]

  this)

(defn left-to-right
  "a strategy that returns the sum of the branches to the left of a position
  in a node"
  [position node]
  (loop [pos position, branch (-> node node-zip z/down), acc 0]
    (let [{:keys [sub-counter element]} (z/node branch)
          acc* (if element (inc acc) acc)]
      (if (= pos 0)
