 
   # If called with a block, iterates over the elements in this set;
   # otherwise, returns this set (this mimics Ruby enumerables).
-  each: (func) -> if func? then @root.each(func) else this
+  each: (func) -> if func? then @items()?.each(func) else this
 
   # Returns the (key,value)-pairs as a stream
   items: -> @root?.elements()

class ArrayNode
  constructor: (progeny, i, node, @size) ->
    @progeny = util.arrayWith(progeny, i, node)

  each: (func) ->
    for node in @progeny
      node.each(func) if node?
    undefined

  elements: -> Stream.fromArray(@progeny).flat_map (n) -> n?.elements()



  size: 1

  elements: -> new Stream(@key)

  get:  (shift, key, data) -> key == @key
