Don't access DomWalker.currentNode until absolutely necessary

Accessing currentNode is quite expensive in most browsers. Do the
cheaper checks first and bail out early if possible.