compatability with python2.7.
added checks for incorrect hierarchy order of ranges in iterator.