code: def add_interval(self, start, end, data=None):
          '''
          Inserts an interval to the tree. 
          Note that when inserting we do not maintain appropriate sorting of the "mid" data structure.
          This should be done after all intervals are inserted.
          '''
          if (end - start) <= 0:
              return
          if self.single_interval is None:
              self.single_interval = (start, end, data)
          elif self.single_interval == 0:
              self._add_interval(start, end, data)
          else:
              self._add_interval(*self.single_interval)
              self.single_interval = 0
              self._add_interval(start, end, data)