       @trigger("noBranchPoints")
       deferred.reject()
 
-  deleteBranch : (nodeID) ->
+  deleteBranch : (node) ->
+
+    if node.type != TYPE_BRANCH then return
 
     i = 0
     while i < @branchStack.length
-      if @branchStack[i].id == nodeID
+      if @branchStack[i].id == node.id
         @branchStack.splice(i, 1)
       else
         i++

    @trees.splice(index, 1)
    # remove comments of all nodes inside that tree
    for node in tree.nodes
      @deleteComment(node.id)
      if deleteBranches and node.type == TYPE_BRANCH
        @deleteBranch(node.id)
    # Because we always want an active tree, check if we need
    # to create one.
    if @trees.length == 0

    deletedNode = @activeNode
    @stateLogger.deleteNode(deletedNode, @activeTree.treeId)

    @deleteBranch(deletedNode.id)
    
    if deletedNode.neighbors.length > 1
      # Need to split tree
