def coalesce(self):
self.sort(key=lambda ts: ts.t0.value)<EOL>i = j = <NUM_LIT:0><EOL>N = len(self)<EOL>while j < N:<EOL><INDENT>this = self[j]<EOL>j += <NUM_LIT:1><EOL>if j < N and this.is_contiguous(self[j]) == <NUM_LIT:1>:<EOL><INDENT>while j < N and this.is_contiguous(self[j]):<EOL><INDENT>try:<EOL><INDENT>this = self[i] = this.append(self[j])<EOL><DEDENT>except ValueError as exc:<EOL><INDENT>if '<STR_LIT>' in str(exc):<EOL><INDENT>this = this.copy()<EOL>this = self[i] = this.append(self[j])<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>j += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>self[i] = this<EOL><DEDENT>i += <NUM_LIT:1><EOL><DEDENT>del self[i:]<EOL>return self<EOL>
Merge contiguous elements of this list into single objects

        This method implicitly sorts and potentially shortens this list.