Apply the same comments from get_before_node since these methods are so similar. This could probably even be refactored to get_pseudo_node to reduce the duplication, but let's see what it looks like without all of the matches.