       (set! moving-key-ix pinned-key-ix)
       (set! pinned-key-ix (- pinned-key-ix 1))
       (set! pinned-key (aget seek-key pinned-key-ix))
-      (aset seek-key moving-key-ix least)))
+      (aset seek-key moving-key-ix least))
+  (mark [this]
+        (.mark iterator))
+  (reset [this]
+         (.reset iterator)))
 
 (defn trieterator [tree]
   (let [it (iterator tree)]

                        (do
                          (set! node (aget (.-children node) ix))
                          (set! ix 0)
                          (recur))))))))))))

(defn iterator [tree]
  (loop [node (.-root tree)]
    (if (nil? (.-children node))
      (if (> (alength (.-keys node)) 0)
        (Iterator. (.-max-keys tree) node 0 false)
        (Iterator. (.-max-keys tree) node 0 true))
      (recur (aget (.-children node) 0)))))

(deftype Trieterator [iterator seek-key ^:mutable pinned-key ^:mutable pinned-key-ix ^:mutable moving-key-ix ^:mutable end?]

            (set! end? true)
            (.search this 1)))))

;; TODO treeterator (key-ix->take?)

(defn intersection [iterators]
  (if (> (alength iterators) 1)
    (if (some #(.-end? %) iterators)
