         i += newChildren.length - 1
       break if rangeIsEmpty
 
-    if @children.length > BRANCHING_THRESHOLD
-      splitIndex = Math.ceil(@children.length / BRANCHING_THRESHOLD)
-      [new Node(@children.slice(0, splitIndex)), new Node(@children.slice(splitIndex))]
+    if newNodes = @splitIfNeeded()
+      newNodes
     else
       addSet(@ids, ids)
       return

    i = 0
    while i < @children.length
      @children[i].delete(id)
      if @children[i - 1]?.shouldMergeWith(@children[i])
        @children.splice(i - 1, 2, @children[i - 1].merge(@children[i]))
      else
        i++

  splice: (position, oldExtent, newExtent, exclusiveIds, precedingIds) ->
    oldRangeIsEmpty = oldExtent.isZero()

      child = @children[i]
      childStart = childEnd
      childEnd = childStart.traverse(child.extent)

      switch childEnd.compare(position)
        when -1 then childPrecedesRange = true
