def sort(self):
        '''
        Must be invoked after all intevals have been added to sort mid_** arrays.
        '''
        if self.single_interval is None or self.single_interval != 0:
            return # Nothing to do for empty and leaf trees.
        self.mid_sorted_by_start.sort(key = lambda x: x[0])
        self.mid_sorted_by_end.sort(key = lambda x: x[1], reverse=True)
        if self.left_subtree is not None:
            self.left_subtree.sort()
        if self.right_subtree is not None:
            self.right_subtree.sort()