    * @param  {Number} right          right border in pixels
    * @return {Number}                middle in pixels
   ###
-  calculateTreeMiddle : (decision, left, right) ->
-
-    if decision.isBranch
-      leftChild = decision.node.children[0]
-      rightChild = decision.node.children[1]
-      return (right - left) * leftChild.width / (leftChild.width + rightChild.width) + left
+  calculateBranchMiddle : (decision, left, right) ->
+
+    leftChild = decision.node.children[0]
+    rightChild = decision.node.children[1]
+    return (right - left) * leftChild.width / (leftChild.width + rightChild.width) + left
+
+
+  calculateMiddle : (left, right) ->
 
     return (left + right) / 2
 

        @drawEdge(left, top + (i - 1) * @nodeDistance, left, top + i * @nodeDistance)


  getNextDecision : (tree) ->

    # Decision point is any point with point.children.length != 1

    @ctx.lineWidth = 1


  drawCommentChain : (decision, left, right, top, mode) ->

    middle = @calculateMiddle(left, right)
    topChild = @calculateChildTreeTop(mode, decision.chainCount, top)
    childNode = decision.node.children[0]
    nodeHasComment = @nodeHasComment(decision.node.id)

    if nodeHasComment
      childNode = decision.node
      topChild -= @nodeDistance

    childTree = @drawTreeWithWidths(childNode, left, right, topChild, mode)

    if !nodeHasComment
      @drawEdge(middle, topChild - @nodeDistance, childTree.middle, childTree.top)

    return middle


  drawBranch : (decision, left, right, top, mode) ->

    branchMiddle = @calculateBranchMiddle(decision, left, right)
    topChildren = @calculateChildTreeTop(mode, decision.chainCount, top)
    leftTree = @drawTreeWithWidths(decision.node.children[0], left,  branchMiddle, topChildren, mode)
    rightTree = @drawTreeWithWidths(decision.node.children[1], branchMiddle, right, topChildren, mode)

    # set the root's x coordinate to be in between the decisionPoint's children
    middle = @calculateMiddle(leftTree.middle, rightTree.middle)

    # draw edges from last node in 'chain' (or root, if chain empty)
    # and the decisionPoint's children
    @drawEdge(middle, topChildren - @nodeDistance, leftTree.middle, leftTree.top)
    @drawEdge(middle, topChildren - @nodeDistance, rightTree.middle, rightTree.top)

    return middle


  drawChainFromTo : (top, left, root, decision) ->

    # Draw the chain and the root, connect them.
