BUG: Fix RecursionError during IntervalTree construction
- [X] closes #25485
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [X] whatsnew entry

Credit to @kingsykes for identifying the issue and determining the fix.