 
 (def test-matrix [:target    { ;; "sorted-set" (sorted-set)
                                "btset"      (btset)}
-                  :distinct? [true false]
+                  ;; :distinct? [true false]
 ;;                   :size    [100 500 1000 2000 5000 10000 20000 50000]
                   :size      [100 500 20000]
                   :method    { "conj"    (fn [opts] (into (:target opts) (:range opts)))

                     ^array xs]
  (cut-n-splice arr 0 (alength arr) idx idx xs))

;; 

(defn ^array replace-keys [^array old-keys ^number idx ^array new-keys]
  (let [new-keys-l (alength new-keys)]    
    (if (and (== 1 new-keys-l)
             (eq (aget new-keys 0) (nth old-keys idx)))
      ;; new key matches old one, can reuse old keys array
      old-keys
      ;; else regular replace
      (splice old-keys idx (inc idx) new-keys))))

(defn lim-key [node]
  (aget (.-keys node) (dec (alength (.-keys node)))))

(deftype Node [keys pointers]
  Object
  
  (append [this path level key]
    (let [idx   (path-get path level)
          nodes (.append (aget pointers idx) path (- level level-shift) key)]
      (if (identical? (aget nodes 0) (aget pointers idx))
        #js [this]
        (let [new-keys     (replace-keys keys     idx           (.map nodes lim-key))
              new-pointers (splice       pointers idx (inc idx) nodes)]
          (if (<= (alength new-pointers) max-len)
          ;; ok as is
          #js [(Node. new-keys new-pointers)]

;; (def s0 (apply btset (range 20000)))
;; (def s1 (into (btset) (range 3)))
;; (apply btset (range 150))

(defn dump [node writer offset]
  (if (instance? LeafNode node)
