     @endOffset               = obj.endOffset
 
   splitBoundaries: ->
-    if @endContainer.nodeType is TEXT_NODE
+    if isTextNode(@endContainer)
       if 0 < @endOffset < @endContainer.length
         if @startContainer is @endContainer
           @commonAncestorContainer = @endContainer.parentNode

          @endContainer = splitText(@endContainer, @endOffset)
          @endOffset = 0

    if @startContainer.nodeType is TEXT_NODE
      if 0 < @startOffset < @startContainer.length
        if @commonAncestorContainer is @startContainer
          @commonAncestorContainer = @commonAncestorContainer.parentNode

    # Get (a copy of) the boundaries of the range.
    {startContainer, startOffset, endContainer, endOffset} = this

    # Move the start container to the last leaf before any sibling boundary,
    # guaranteeing that any children of the container are within the range.
    if startContainer.childNodes.length and startOffset > 0
      startContainer = lastLeaf(startContainer.childNodes[startOffset-1])
      startOffset = startContainer.length or startContainer.childNodes.length

    # Move the end container to the first leaf after any sibling boundary,
    # guaranteeing that any children of the container are within the range.
    if endOffset < endContainer.childNodes.length
      endContainer = firstLeaf(endContainer.childNodes[endOffset])
      endOffset = 0

    # These above implies that a post-order traversal visits every Node in the
    # Range before visiting the end container. The first Node in the order is
    # the first leaf of the start container.
    from = firstLeaf(startContainer)

    # Similarly, a post-order traversal that reverses the child order visits
    # every Node in the Range before visiting the end container. The first
    # Node in the order is the last leaf of the start container.
    to = lastLeaf(endContainer)

    # Any TextNode in the traversal is valid unless excluded by the offset.
    checkNode = (node) ->
      if not isTextNode(node) then return false
      if node is startContainer and startOffset > 0 then return false
      if node is endContainer and endOffset == 0 then return false
      return true

    # Find the start and end TextNode nodes.
    start = findNode(from, to, checkNode, postFirst)
    end = findNode(to, from, checkNode, postLast)

    return new NormalizedRange({commonAncestor, start, end})

