     @recordWidths(root)
     @drawTreeWithWidths(root, @NODE_RADIUS, @canvas.width() - @NODE_RADIUS, @nodeDistance, mode)
 
+    # because of z layering all nodes have to be drawn last
+    @drawAllNodes()
+
 
   drawTreeWithWidths : (tree, left, right, top, mode) ->
 

    hasActiveNode = @chainContainsActiveNode(tree, decision.node)

    # Draw root, chain indicator and decision point
    @drawNode(middle, top, tree.id)
    @drawEdge(middle, top, middle, top + 0.5 * @nodeDistance)
    @drawChainIndicator(middle, top + 0.5 * @nodeDistance, top + 1.5 * @nodeDistance, hasActiveNode)
    @drawEdge(middle, top + 1.5 * @nodeDistance, middle, top + 2 * @nodeDistance)
    @drawNode(middle, top + 2 * @nodeDistance, decision.node.id)


  getNextDecision : (tree) ->

    # Draw the chain and the root, connect them.
    node = root
    for i in [0..decision.chainCount]
      @addNode(left, top + i * @nodeDistance, node.id)
      node = node.children[0]
      if i != 0
        @drawEdge(left, top + (i - 1) * @nodeDistance, left, top + i * @nodeDistance)
