code for interval tree