       childStart = childEnd
       childEnd = childStart.traverse(child.extent)
 
+      switch childEnd.compare(start)
+        when -1 then childPrecedesRange = true
+        when 1  then childPrecedesRange = false
+        when 0
+          if child.hasEmptyRightmostLeaf()
+            childPrecedesRange = false
+          else
+            childPrecedesRange = true
+            if rangeIsEmpty
+              ids = new Set(ids)
+              child.findContaining(child.extent, ids)
+      continue if childPrecedesRange
+
       switch childStart.compare(end)
         when -1 then childFollowsRange = false
-        when 0  then childFollowsRange = not child.hasEmptyLeftmostLeaf() and not rangeIsEmpty
         when 1  then childFollowsRange = true
+        when 0  then childFollowsRange = not (child.hasEmptyLeftmostLeaf() or rangeIsEmpty)
       break if childFollowsRange
-
-      switch childEnd.compare(start)
-        when -1 then childPrecedesRange = true
-        when 0  then childPrecedesRange = not child.hasEmptyRightmostLeaf()
-        when 1  then childPrecedesRange = false
-      continue if childPrecedesRange
 
       relativeStart = Point.max(Point.zero(), start.traversalFrom(childStart))
       relativeEnd = Point.min(child.extent, end.traversalFrom(childStart))
       if newChildren = child.insert(ids, relativeStart, relativeEnd)
         @children.splice(i - 1, 1, newChildren...)
         i += newChildren.length - 1
+      break if rangeIsEmpty
 
     if @children.length > BRANCHING_FACTOR
       splitIndex = Math.ceil(@children.length / BRANCHING_FACTOR)

Point = require "./point"
Range = require "./range"
{setEqual, subtractSet, addSet, intersectSet} = require "./set-helpers"

BRANCHING_FACTOR = 3


    @rootNode = new Leaf(Point.infinity(), new Set)

  insert: (id, start, end) ->
    if splitNodes = @rootNode.insert(new Set().add(id), start, end)
      @rootNode = new Node(splitNodes)

  delete: (id) ->
