          (set! root (Node. nil nil #js [] #js [] nil nil nil)))
   (toString [this]
             (pr-str (into (sorted-map-by key-compare) (map vec this))))
-  (update [this key delta]
-          (assert (not (== delta 0)))
-          (.update root key delta max-keys))
+  (add [this key]
+       (.add root key max-keys))
+  (del [this key]
+       (.del root key max-keys))
   (push! [this ix key&val&child which-child]
            (let [left-child (if (== which-child left-child) (aget key&val&child 2) root)
                  right-child (if (== which-child right-child) (aget key&val&child 2) root)]

(defn gen-update [key-len]
  (gen/make-gen
   (fn [rnd size]
     (let [key (make-simple-key rnd size key-len)
           delta (make-simple-delta rnd size)]
         [[:update key delta] nil]))))

(defn apply-to-tree [tree updates]
  [tree
   (doall
    (for [update updates]
      (.update tree (nth update 1) (nth update 2))))])

(defn apply-to-sorted-map [map updates]
  (let [map (atom map)
        results (doall
                 (for [update updates]
                   (let [key (nth update 1)
                         delta (nth update 2)
                         old-val (get @map key 0)
                         new-val (+ old-val delta)]
                     (if (== new-val 0)
                       (swap! map dissoc key)
                       (swap! map assoc key new-val))
                     (cond
                      (and (== old-val 0) (not (== new-val 0))) added
                      (and (not (== old-val 0)) (not (== new-val 0))) changed
                      (and (not (== old-val 0)) (== new-val 0)) deled))))]
    [@map results]))

(defn run-building-prop [min-keys key-len updates]


(deftype Node [parent parent-ix keys vals children ^:mutable lower ^:mutable upper]
  Object
  (add [this key max-keys]
       (let [ix (key-find-gte keys key)]
            (if (and (< ix (alength keys)) (key= key (aget keys ix)))
              false
              (if (nil? children)
                (do
                  (.push! this ix #js [key nil])
                  (.maintain! this max-keys)
                  true)
                (.add (aget children ix) key max-keys)))))
  (del [this key max-keys]
       (let [ix (key-find-gte keys key)]
            (if (and (< ix (alength keys)) (key= key (aget keys ix)))
              (if (nil? children)
                (do
                  (.pop! this ix)
                  (.maintain! this max-keys)
                  true)
                (loop [node (aget children (+ ix 1))]
                  (if (not (nil? (.-children node)))
                    (recur (aget (.-children node) 0))
                    (do
                      (aset keys ix (aget (.-keys node) 0))
                      (aset vals ix (aget (.-vals node) 0))
                      (.pop! node 0)
                      (.maintain! node max-keys)
                      (.maintain! this max-keys)
                      true))))
              (if (nil? children)
                false
                (.del (aget children ix) key max-keys)))))
  (push! [this ix key&val&child which-child] ;; on leaves, child and which-child are not required
         (.splice keys ix 0 (aget key&val&child 0))
         (.splice vals ix 0 (aget key&val&child 1))
