Implementation of an interval tree in Scala