           (apush result #js [(aget keys ix) (aget vals ix)]))
         (when-not (nil? children)
           (.into (aget children (alength keys)) result)))
+  ;; TODO worth doing binary search here when nodes are large
   (seek [this key ix]
         (let [len (alength keys)]
           (loop [ix ix]

          nil)))

(defn iterator [tree]
  (Iterator. (.-max-keys tree) (.-root tree) 0))

(defn tree [min-keys]
  (let [node (Node. nil nil #js [] #js [] nil)

    (js/console.log tree)
    (seq tree))

  (let [tree (tree 3)]
    (dotimes [i 1000]
      (.assoc! tree i (* 2 i)))
    (= (map #(.apply vector nil %) (seq tree)) (for [i (range 1000)] [i (* 2 i)])))

  (time
   (let [tree (tree 1)]
     (dotimes [i 100000]
       (.assoc! tree i (* 2 i)))))

  (time
   (let [tree (tree 3)]
     (dotimes [i 100000]
       (.assoc! tree i (* 2 i)))))

  (time
   (let [tree (tree 10)]
     (dotimes [i 100000]
       (.assoc! tree i (* 2 i)))))

  (time
   (let [tree (tree 1000)]
     (dotimes [i 100000]
       (.assoc! tree i (* 2 i)))))

  (let [tree (tree 3)
        iterator (iterator tree)]
    (take 2000 (take-while identity (repeatedly #(.next iterator)))))

  (let [tree (tree 3)
        _ (.assoc! tree :a 0)
        iterator (iterator tree)]
    (take 2000 (take-while identity (repeatedly #(.next iterator)))))

  (let [tree (tree 3)
        _ (dotimes [i 1000]
            (.assoc! tree i (* 2 i)))
        iterator (iterator tree)]
    (take 2000 (take-while identity (repeatedly #(.next iterator)))))
  )
