completed mapIntervalsToTree()