     (let [keys-l (node-len node)]
       (if (== 0 level)
         (let [keys (.-keys ^Leaf node)
-              idx  (binary-search-l (.-comparator set) keys 0 (dec keys-l) key)]
+              idx  (binary-search-l (.-comparator set) keys (dec keys-l) key)]
           (if (== keys-l idx) -1 (path-set path 0 idx)))
         (let [keys (.-keys ^Node node)
-              idx  (binary-search-l (.-comparator set) keys 0 (- keys-l 2) key)]
+              idx  (binary-search-l (.-comparator set) keys (- keys-l 2) key)]
           (recur (shim/aget (.-pointers ^Node node) idx)
                  (path-set path level idx)
                  (- level level-shift)))))))

    (-meta [_] meta)

    IEmptyableCollection
    (-empty [_] (BTSet. (Leaf. (array)) 0 0 comparator meta uninitialized-hash))

    IEquiv
    (-equiv [this other]

(def ^:const path-mask (dec (bit-shift-left 1 level-shift)))
(def ^:const empty-path 0)

(defn path-get ^long [^long path ^long level]
  (bit-and path-mask
           (unsigned-bit-shift-right path level)))

(defn path-set ^long [^long path ^long level ^long idx]
  (bit-or path 
          (bit-shift-left idx level)))

(defn binary-search-l ^long [cmp arr ^long r k]
  (loop [l 0
         r (long r)]
    (if (<= l r)
      (let [m  (shim/half (+ l r))
            mk (shim/aget arr m)]
        (if (neg? (cmp mk k))
          (recur (inc m) r)
          (recur l (dec m))))
      l)))


(defn binary-search-r ^long [cmp arr ^long r k]
  (loop [l 0
         r (long r)]
    (if (<= l r)
      (let [m  (shim/half (+ l r))
            mk (shim/aget arr m)]
        (if (pos? (cmp mk k))
          (recur l (dec m))
          (recur (inc m) r)))
      l)))

(defn lookup-exact ^long [cmp arr key]
  (let [arr-l (shim/alength arr)
        idx   (binary-search-l cmp arr (dec arr-l) key)]
    (if (and (< idx arr-l)
             (== 0 (cmp (shim/aget arr idx) key)))
      idx
      -1)))

(defn lookup-range ^long [cmp arr key]
  (let [arr-l (shim/alength arr)
        idx   (binary-search-l cmp arr (dec arr-l) key)]
    (if (== idx arr-l)
      -1
      idx)))
