cloned from here: https://github.com/ekg/intervaltree