nodes: 0, module; 1, function_definition; 2, function_name:add_interval; 3, parameters; 4, block; 5, identifier:self; 6, identifier:start; 7, identifier:end; 8, default_parameter; 9, expression_statement; 10, comment:# Ignore intervals of 0 or negative length; 11, if_statement; 12, if_statement; 13, identifier:data; 14, None; 15, string:'''
          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.
          '''; 16, comparison_operator:(end - start) <= 0; 17, block; 18, comparison_operator:self.single_interval is None; 19, comment:# This is an empty tree and we are adding the first interval. Just record it in a field.; 20, block; 21, elif_clause; 22, else_clause; 23, parenthesized_expression; 24, integer:0; 25, return_statement; 26, attribute; 27, None; 28, expression_statement; 29, comparison_operator:self.single_interval == 0; 30, comment:# This is a usual tree, use standard addition method; 31, block; 32, comment:# This is a tree with a single interval. Convert to a usual tree.; 33, block; 34, binary_operator:end - start; 35, identifier:self; 36, identifier:single_interval; 37, assignment; 38, attribute; 39, integer:0; 40, expression_statement; 41, expression_statement; 42, expression_statement; 43, expression_statement; 44, identifier:end; 45, identifier:start; 46, attribute; 47, tuple; 48, identifier:self; 49, identifier:single_interval; 50, call; 51, call; 52, assignment; 53, call; 54, identifier:self; 55, identifier:single_interval; 56, identifier:start; 57, identifier:end; 58, identifier:data; 59, attribute; 60, argument_list; 61, attribute; 62, argument_list; 63, attribute; 64, integer:0; 65, attribute; 66, argument_list; 67, identifier:self; 68, identifier:_add_interval; 69, identifier:start; 70, identifier:end; 71, identifier:data; 72, identifier:self; 73, identifier:_add_interval; 74, list_splat; 75, identifier:self; 76, identifier:single_interval; 77, identifier:self; 78, identifier:_add_interval; 79, identifier:start; 80, identifier:end; 81, identifier:data; 82, attribute; 83, identifier:self; 84, identifier:single_interval
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.
          '''
          # Ignore intervals of 0 or negative length
          if (end - start) <= 0:
              return
          if self.single_interval is None:
              # This is an empty tree and we are adding the first interval. Just record it in a field.
              self.single_interval = (start, end, data)
          elif self.single_interval == 0:
              # This is a usual tree, use standard addition method
              self._add_interval(start, end, data)
          else:
              # This is a tree with a single interval. Convert to a usual tree.
              self._add_interval(*self.single_interval)
              self.single_interval = 0
              self._add_interval(start, end, data)