     # Find the start and end TextNode.
     checkStart = (node) ->
       if checkNode(node) then start = node
-      return not (start or node is last)
+      return start or node is last
 
     checkEnd = (node) ->
       if checkNode(node) then end = node
-      return not (end or node is start)
+      return end or node is start
 
     someNode(startContainer, checkStart)
     someNode(endContainer, checkEnd, preLast)

    }


# Return true if the given predicate is true for any Node of the tree.
# The predicate function is invoked once for each Node in the tree.
# An optional third argument specifies a traversal order and should be a
# function that takes a Node and returns its successor. The default order is
# DOM position order (pre-order).
someNode = (node, fn, successor = preFirst) ->
  result = false
  node = successor(node) while result = fn(node)
  return result


# Return an Array of each Node in the tree for which the predicate is true.
filterNode = (root, fn = (-> true)) ->
  result = []
  last = lastLeaf(root)

  collect = (node) ->
    if fn(node) then result.push(node)
    return node isnt last

  someNode(root, collect)

  return result


# Split a TextNode at an offset, returning the successor.

      first = firstLeaf(bounds)
      checkEnd = (node) ->
        if isTextNode(node) then end = node
        return end or node is first
      someNode(bounds, checkEnd, preLast)
      @end = end

