   },
 ]
 
-
 class NodeCollection
   constructor: (@shape) ->
     @nodes = []
     @animations = []
 
-  copyNodesFrom: (nc) ->
+  takeNodesFrom: (nc) ->
     @nodes = nc.nodes
 
-  addLeaves: (dict, pos) ->
-    length = 0
-    for value of dict
-      length += 1
-
-    i = 0
-    for label, value of dict
-      leaf = new Leaf(value, label, @shape)
-      @nodes.push(leaf)
-      leaf.x = pos.x + (i / length - .5 ) * 3 * leaf.radius * length
-      leaf.y = pos.y
-
-      i += 1
+    rvFn = (node) ->
+      if node.value?
+        node.saved_value = node.value
+      delete node.value
+
+    for n in @nodes
+      n.forAll(rvFn)
 
   render: (ctx, idx, t) ->
     if @animations.length > 0

    action: (c, t) ->
      console.log('finish Huffman')
      # TODO: maybe first this should automatically finish the construction?
      c.reconstruct_as = NodeCollection
  }
]


        else
          letters[c] = 1

    collection = new WeightedNodeCollection(shapes[next_shape])
    next_shape = (next_shape + 1) % shapes.length
    collection.addLeaves( letters, pos )
    collections.push(collection)
