          (assert (> (alength marked-nodes) 0))
          (assert (> (alength marked-ixes) 0))
          (set! node (.pop marked-nodes))
-         (set! ix (.pop marked-ixes))))
+         (set! ix (.pop marked-ixes))
+         (.maintain this)))
 
 (defn iterator [tree]
   (loop [node (.-root tree)]

        (aset pinned-key moving-key-ix greatest))
      (.maintain this))
  (mark [this]
        (.mark iterator))
  (reset [this]
         (.reset iterator)))

(defn trieterator [iterator]
  (let [trieterator (Trieterator. iterator (least-key (.-key-len iterator)) (greatest-key (.-key-len iterator)) 0 false (.-key-len iterator))]
    (.maintain trieterator)
    trieterator))


                 movements (gen/vector (gen-next key-len))] ;; TODO use gen-movement once Treeterator supports seek
                (run-self-join-prop min-keys key-len actions movements)))

(defn run-product-join-prop [min-keys key-len actions movements]
  (let [tree (apply-to-tree (tree min-keys key-len) actions)
        iterator-results (apply-to-iterator (iterator tree) movements)
        iterator-a (trieterator (iterator tree))
        iterator-b (trieterator (iterator tree))
        join-results (apply-to-iterator
                      (treeterator (join #js [iterator-a iterator-b] (* 2 key-len) #js [(into-array (range key-len)) (into-array (range key-len (* 2 key-len)))]))
                      movements)]
    (= (map vec iterator-results) (map vec join-results))))

(defn product-join-prop [key-len]
  (prop/for-all [min-keys gen/s-pos-int
                 actions (gen/vector (gen-action key-len))
                 movements (gen/vector (gen-next key-len))] ;; TODO use gen-movement once Treeterator supports seek
                (run-product-join-prop min-keys key-len actions movements)))

(comment
  (dc/quick-check 1000 (least-prop 1))
  (dc/quick-check 1000 (least-prop 2))
