                  movements (gen/vector (gen-movement key-len))]
                 (run-iterator-prop min-keys key-len actions movements)))
 
+;; BROKEN by changing Intersection to work on values instead of arrays
 (defn run-intersection-prop [min-keys key-len actionss movements]
   (let [trees (map #(apply-to-tree (tree min-keys key-len) %) actionss)
         keys (apply clojure.set/intersection (map #(set (map (fn [[k v]] (vec k)) %)) trees))

    (.maintain trieterator)
    trieterator))

;; works on trees
(deftype Intersection [iterators ^:mutable end? key-len]
  Object
  (key [this]
       (when (false? end?)
         (.key (aget iterators 0))))
  (search [this current]
          (when (false? end?)
            (loop [current current]
              (let [max-key (.key (aget iterators (mod (- current 1) (alength iterators))))
                    min-key (.key (aget iterators current))]
                (when-not (key= min-key max-key)
                  (.seek (aget iterators current) max-key)
                  (if (true? (.-end? (aget iterators current)))
                    (set! end? true)

  (dc/quick-check 10000 (trie-tree-prop 1))
  (dc/quick-check 10000 (trie-tree-prop 2))
  (dc/quick-check 10000 (trie-tree-prop 3))
  (dc/quick-check 10000 (self-join-prop 1))
  (dc/quick-check 100 (self-join-prop 2))
  (dc/quick-check 100 (self-join-prop 3))

