refactor and make reversed(range()) optimisation apply only to known bounds, not any non-NameNode