                 (assert (= (count keys) (count vals) (dec (count children))) (pr-str keys vals children))
                 (assert (= lower (.-lower (aget children 0))) (pr-str lower (.-lower (aget children 0))))
                 (assert (= upper (.-upper (aget children (- (alength children) 1)))) (pr-str upper (.-upper (aget children (- (alength children) 1)))))
-                (assert (every? #((fn [a b] (gt a b)) (aget keys %) (.-upper (aget children %))) (range (count keys))))
-                (assert (every? #((fn [a b] (lt a b)) (aget keys %) (.-lower (aget children (inc %)))) (range (count keys))))
+                (assert (every? #(gt-fun (aget keys %) (.-upper (aget children %))) (range (count keys))))
+                (assert (every? #(lt-fun (aget keys %) (.-lower (aget children (inc %)))) (range (count keys))))
                 (dotimes [i (count children)] (.valid! (aget children i) max-keys))))))
   (pretty-print [this]
                 (str "(" parent-ix ")" "|" (pr-str lower) " " (pr-str (vec keys)) " " (pr-str upper) "|")))
+
+;; 'bool' < 'number' < 'string' < 'undefined'
+(def least false)
+(def greatest js/undefined)
+
+(defn tree [min-keys]
+  (let [node (Node. nil nil #js [] #js [] nil greatest least)
+        tree (Tree. (* 2 min-keys) node)]
+    (set! (.-parent node) tree)
+    (set! (.-parent-ix node) 0)
+    tree))
 
 (deftype Iterator [max-keys ^:mutable node ^:mutable ix ^:mutable end?]
   Object

              (assert (>= (count keys) min-keys) (pr-str keys min-keys)))
            (assert (<= (count keys) max-keys) (pr-str keys max-keys))
            (assert (= (count keys) (count (set keys))))
            (assert (= (seq keys) (seq (sort-by identity #(cond (== %1 %2) 0 (lt %1 %2) -1 (gt %1 %2) 1) keys))))
            (assert (every? #(lte lower %) keys) (pr-str lower keys))
            (assert (every? #(gte upper %) keys) (pr-str upper keys))
            (if (nil? children)


(defn run-building-prop [min-keys actions]
  (let [tree (apply-to-tree (tree min-keys) actions)
        sorted-map (apply-to-sorted-map (sorted-map-by compare-keys) actions)]
    (and (= (seq (map vec tree)) (seq sorted-map))
         (.valid! tree))))

