It may be useful to add a parameter for a stop condition for users who don't want to only stop when the current node is null.