   (-lookup [set k]
     (-lookup set k nil))
   (-lookup [set k not-found]
-    (let [found (get-key set (seek set k))]
+    (let [found (key-for set (seek set k))]
       (if (eq found k) found not-found)))
 
   ISeqable
   (-seq [this]
-    (when (pos? (alength (.-keys root)))
-      (BTSetIter. this 0))))
+    (btset-iter this))
+  
+  IPrintWithWriter
+  (-pr-writer [this writer opts]
+    (pr-sequential-writer writer pr-writer "#{" " " "}" opts (seq this))))
+
+(defn btset-by
+  ([cmp] (BTSet. (LeafNode. (array)) 0 cmp))
+  ([cmp & keys]
+    (reduce -conj (btset-by cmp) keys)))
 
 (defn btset
-  ([] (btset compare))
-  ([cmp]
-    (BTSet. (LeafNode. (array)) 1 cmp)))
+  ([] (btset-by compare))
+  ([& keys]
+    (reduce -conj (btset) keys)))
 
 ;; helpers
 
-(defn parse-path [path]
-  (loop [path path
-         res  []]
-    (if (not= path 0)
-      (recur (unsigned-bit-shift-right path path-bit-offset)
-             (conj res (bit-and path path-mask)))
-      res)))
-
-(def seek-h (comp parse-path seek))
+(defn parse-path [path shift]
+  (loop [level shift
+         res   []]
+    (if (pos? level)
+      (recur (- level level-shift)
+             (conj res (path-get path level))))))
+
+(defn seek-h [set key]
+  (parse-path (seek set key) (.-shift set)))
+
+;; (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)

  (^array [^array arr ^number cut-from ^number cut-to]
    (.slice arr cut-from cut-to)))

(defn splice ^array [^array  arr
                     ^number splice-from
                     ^number splice-to
                     ^array  xs]
  (cut-n-splice arr 0 (alength arr) splice-from splice-to xs))

(defn insert ^array [^array arr
                     ^number idx
                     ^array xs]
  (cut-n-splice arr 0 (alength arr) idx idx xs))

;; 

(defn replace-keys ^array [^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)))


(deftype Node [keys pointers]
  Object
  
  (append [_ path level key]
    (let [idx          (path-get path level)
          nodes        (.append (aget pointers idx) path (- level level-shift) key)
          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)]
