       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)
+    # The above implies that a pre-order traversal visits every Node in the
+    # Range before visiting the last leaf of the end container.
+    first = firstLeaf(startContainer)
+
+    # Similarly, a pre-order traversal that reverses the children visits every
+    # Node in the Range before visiting the first leaf of the start container.
+    last = lastLeaf(endContainer)
 
     # Any TextNode in the traversal is valid unless excluded by the offset.
     checkNode = (node) ->

      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})


  if pass then return node else return null


# Return the next Node in a first-to-last-child pre-order traversal.
preFirst = (node) ->
  if node.firstChild?
    return node.firstChild

  while not node.nextSibling?
    node = node.parentNode
    if node is null then return null

  return node.nextSibling


# Return the next Node in a last-to-first-child pre-order traversal.
preLast = (node) ->
  if node.lastChild?
    return node.lastChild

  while not node.previousSibling?
    node = node.parentNode
    if node is null then return null

  return node.previousSibling


# Find the first leaf node.
