          (.reset iterator)))
 
 (defn trieterator [iterator]
-  (let [trieterator (Trieterator. iterator (greatest-key (.-key-len iterator)) nil -1 0 false (.-key-len iterator))]
+  (let [trieterator (Trieterator. iterator (greatest-key (.-key-len iterator)) (greatest-key (.-key-len iterator)) 0 false (.-key-len iterator))]
     (.maintain trieterator)
     trieterator))
 

      (recur (aget (.-children node) 0)))))

;; trie view of a tree
(deftype Trieterator [iterator seek-key ^:mutable pinned-key ^:mutable pinned-key-ix ^:mutable moving-key-ix ^:mutable end? key-len]
  Object
  (key [this]
       (when (false? end?)

         (.val iterator)))
  (maintain [this]
            (if (or (true? (.-end? iterator))
                    (not (key-lt (.key iterator) pinned-key)))
              (set! end? true)
              (do
                (set! end? false)
                (aset seek-key moving-key-ix (.key this))))) ;; is this needed?
  (next [this]
        (when (false? end?)
          (.seek iterator seek-key)
