     @recordWidths(root)
     @drawTreeWithWidths(root, @NODE_RADIUS, @canvas.width() - @NODE_RADIUS, @nodeDistance, mode)
 
+
   drawTreeWithWidths : (tree, left, right, top, mode) ->
 
     # get the decision point
-    decisionPoint = @getNextDecisionPoint(tree)
-
-    # TODO: algorithm expects all decision points to be branch points
-    # though a normal point with comment only has one child --> refactor this
-
-    middle = @calculateTreeMiddle(decisionPoint, left, right)
-    chainCount = @calculateChainCount(tree)
+    decision = @getNextDecision(tree)
+    middle = @calculateTreeMiddle(decision.node, left, right)
     rootX = middle # if decisionPoint is leaf, there's not much to do
 
     # if the decision point has 2 children, draw them and remember their position
-    if decisionPoint.children.length > 1
-
-      topChildren = @calculateChildTreeTop(mode, chainCount, top)
-      c1 = @drawTreeWithWidths(decisionPoint.children[0], left,  middle, topChildren, mode)
-      c2 = @drawTreeWithWidths(decisionPoint.children[1], middle, right, topChildren, mode)
+    if decision.isBranch
+
+      topChildren = @calculateChildTreeTop(mode, decision.chainCount, top)
+      leftTree = @drawTreeWithWidths(decision.node.children[0], left,  middle, topChildren, mode)
+      rightTree = @drawTreeWithWidths(decision.node.children[1], middle, right, topChildren, mode)
 
       # set the root's x coordinate to be in between the decisionPoint's children
-      rootX = (c1.rootX + c2.rootX) / 2
+      rootX = (leftTree.rootX + rightTree.rootX) / 2
 
       # draw edges from last node in 'chain' (or root, if chain empty)
       # and the decisionPoint's children
-      @drawEdge(rootX, topChildren - @nodeDistance, c1.rootX, c1.top)
-      @drawEdge(rootX, topChildren - @nodeDistance, c2.rootX, c2.top)
-
-    if mode == @MODE_NORMAL or chainCount < 3
+      @drawEdge(rootX, topChildren - @nodeDistance, leftTree.rootX, leftTree.top)
+      @drawEdge(rootX, topChildren - @nodeDistance, rightTree.rootX, rightTree.top)
+
+    if mode == @MODE_NORMAL or decision.chainCount < 3
       # Draw the chain and the root, connect them.
       node = tree
-      for i in [0..chainCount]
+      for i in [0..decision.chainCount]
         @drawNode(rootX, top + i * @nodeDistance, node.id)
         node = node.children[0]
         if i != 0

    unless tree
      return count

    # One decision point
    count++

    # Count non decision points
    chainCount = 0
    while tree.children.length == 1
      tree = tree.children[0]
      chainCount++
    if mode == @MODE_NOCHAIN
      chainCount = Math.min(chainCount, 2)
    count += chainCount

    if tree.children.length == 0
      return count
    return Math.max(@getMaxTreeDepth(tree.children[0], mode, count),
              @getMaxTreeDepth(tree.children[1], mode, count))


  getIdFromPos : (x, y) =>

      child2 = decisionPoint.children[1]
      return (right - left) * child1.width / (child1.width + child2.width) + left


  # Calculate the top of the children
  calculateChildTreeTop : (mode, chainCount, top) ->
