Correctly handle reaching the end of the interval tree. (Bug#15344)