                  (catvec op-buf (:op-buf other))
                  cfg))
   (lookup [root key]
-    (let [x (Collections/binarySearch (index-node-keys children) key compare)]
+    ;;This is written like so because it's performance critical
+    (let [l (dec (count children))
+          a (object-array l)
+          _ (dotimes [i l]
+              (aset a i (last-key (nth children i))))
+          x (Arrays/binarySearch a 0 l key compare)]
       (if (neg? x)
         (- (inc x))
         x))))

            [taoensso.nippy :as nippy]
            [clojure.pprint :as pp])
  (:import java.io.Writer
           java.util.Collections))

(defrecord Config [index-b data-b op-buf-size])

(defn insert
  [{:keys [cfg] :as tree} key]
  (let [path (lookup-path tree key) ; don't care about the found key or its index
        {:keys [children] :or {children (sorted-set-by compare)}} (peek path)
        updated-data-node (data-node cfg (conj children key))]
    (loop [node updated-data-node
           path (pop path)]
