Rewrite DomUtils.getNodesInRange to improve performance

By reducing the number of boundaries being checked, iteration performance
is boosted quite significantly for text node retrieval.