In the case where a text node is the left (resp. right) sibling of the target node and that text node is the first (resp. last) child of its parent, this method will return `text` but no `element`. Looking at the logic of the rest of the algorithm, I think that's actually fine, but it might be good to clarify that here (currently the docs for the return value are written as if `text` will only be set if `element` is set).