nodes: 0, module; 1, function_definition; 2, function_name:coalesce; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, while_statement; 11, delete_statement; 12, return_statement; 13, comment:"""Merge contiguous elements of this list into single objects
  
          This method implicitly sorts and potentially shortens this list.
          """; 14, call; 15, assignment; 16, assignment; 17, comparison_operator:j < N; 18, block; 19, subscript; 20, identifier:self; 21, attribute; 22, argument_list; 23, identifier:i; 24, assignment; 25, identifier:N; 26, call; 27, identifier:j; 28, identifier:N; 29, expression_statement; 30, expression_statement; 31, if_statement; 32, expression_statement; 33, identifier:self; 34, slice; 35, identifier:self; 36, identifier:sort; 37, keyword_argument; 38, identifier:j; 39, integer:0; 40, identifier:len; 41, argument_list; 42, assignment; 43, augmented_assignment; 44, boolean_operator; 45, block; 46, else_clause; 47, augmented_assignment; 48, identifier:i; 49, identifier:key; 50, lambda; 51, identifier:self; 52, identifier:this; 53, subscript; 54, identifier:j; 55, integer:1; 56, comparison_operator:j < N; 57, comparison_operator:this.is_contiguous(self[j]) == 1; 58, while_statement; 59, block; 60, identifier:i; 61, integer:1; 62, lambda_parameters; 63, attribute; 64, identifier:self; 65, identifier:j; 66, identifier:j; 67, identifier:N; 68, call; 69, integer:1; 70, boolean_operator; 71, block; 72, expression_statement; 73, identifier:ts; 74, attribute; 75, identifier:value; 76, attribute; 77, argument_list; 78, comparison_operator:j < N; 79, call; 80, try_statement; 81, expression_statement; 82, assignment; 83, identifier:ts; 84, identifier:t0; 85, identifier:this; 86, identifier:is_contiguous; 87, subscript; 88, identifier:j; 89, identifier:N; 90, attribute; 91, argument_list; 92, block; 93, except_clause; 94, augmented_assignment; 95, subscript; 96, identifier:this; 97, identifier:self; 98, identifier:j; 99, identifier:this; 100, identifier:is_contiguous; 101, subscript; 102, expression_statement; 103, as_pattern; 104, block; 105, identifier:j; 106, integer:1; 107, identifier:self; 108, identifier:i; 109, identifier:self; 110, identifier:j; 111, assignment; 112, identifier:ValueError; 113, as_pattern_target; 114, if_statement; 115, identifier:this; 116, assignment; 117, identifier:exc; 118, comparison_operator:'cannot resize this array' in str(exc); 119, block; 120, else_clause; 121, subscript; 122, call; 123, string; 124, call; 125, expression_statement; 126, expression_statement; 127, block; 128, identifier:self; 129, identifier:i; 130, attribute; 131, argument_list; 132, string_content:cannot resize this array; 133, identifier:str; 134, argument_list; 135, assignment; 136, assignment; 137, raise_statement; 138, identifier:this; 139, identifier:append; 140, subscript; 141, identifier:exc; 142, identifier:this; 143, call; 144, identifier:this; 145, assignment; 146, identifier:self; 147, identifier:j; 148, attribute; 149, argument_list; 150, subscript; 151, call; 152, identifier:this; 153, identifier:copy; 154, identifier:self; 155, identifier:i; 156, attribute; 157, argument_list; 158, identifier:this; 159, identifier:append; 160, subscript; 161, identifier:self; 162, identifier:j
code: def coalesce(self):
          """Merge contiguous elements of this list into single objects
  
          This method implicitly sorts and potentially shortens this list.
          """
          self.sort(key=lambda ts: ts.t0.value)
          i = j = 0
          N = len(self)
          while j < N:
              this = self[j]
              j += 1
              if j < N and this.is_contiguous(self[j]) == 1:
                  while j < N and this.is_contiguous(self[j]):
                      try:
                          this = self[i] = this.append(self[j])
                      except ValueError as exc:
                          if 'cannot resize this array' in str(exc):
                              this = this.copy()
                              this = self[i] = this.append(self[j])
                          else:
                              raise
                      j += 1
              else:
                  self[i] = this
              i += 1
          del self[i:]
          return self