   (maintain [this]
             (set! end? (.-end? (aget key-ix->intersection key-ix))))
   (next [this]
-        (when (false? end)
+        (when (false? end?)
           (.next (aget key-ix->intersection key-ix))
           (.maintain this)))
   (seek [this key]
-        (when (false? end)
+        (when (false? end?)
           (.seek (aget key-ix->intersection key-ix) key)
           (.maintain this)))
   (down [this]

  (assert (every? #(= (.-key-len (aget iterators 0)) (.-key-len %)) iterators))
  (if (> (alength iterators) 1)
    (if (some #(.-end? %) iterators)
      (Intersection. iterators true)
      (let [intersection (Intersection. (into-array (sort-by #(.key %) key-compare iterators)) false (.-key-len (aget iterators 0)))]
        (.search intersection 0)
        intersection))

        (assert false "TODO")))

(defn treeterator [iterator]
  (let [treeterator (Treeterator. iterator (least-key (.-key-len iterator)) 0 (.-end? iterator) (.-key-len iterator))]
    (.walk-down treeterator)
    treeterator))

