     nodeMap = {}
 
     for topState in tree
-        walk topState, (state) ->
+        walk topState, (state, parent) ->
             node = {
                 name: state.name
-                radius: 20
+                width: 40
+                height: 40
+                children: []
             }
             nodes.push(node)
             nodeMap[state.name] = node
+            if parent?
+                parentNode = nodeMap[parent.name]
+                node.parent = parentNode
+                parentNode.children.push(node)
 
     r = 40
 

    return children


walk = (state, callback) ->
    callback(state)
    for child in state.children or []
        walk(child, callback)


drawTree = (svg, tree) ->


        svg.selectAll('.cell')
            .attr('transform', (node) -> "translate(#{node.x},#{node.y})")

        svg.selectAll('.cell rect')
            .attr('x', (node) -> - node.width / 2)
            .attr('y', (node) -> - node.height / 2)
            .attr('width', (node) -> node.width)
            .attr('height', (node) -> node.height)


collide = (node) ->
