code: def merge_intervals(elems, overlap_thres=2.0):
      overlap_thres = max(0.0, overlap_thres)
      ordered = sorted(elems, key=lambda e: e.x0)
      intervals = []
      cur = [-overlap_thres, -overlap_thres]
      for e in ordered:
          if e.x0 - cur[1] > overlap_thres:
              if cur[1] > 0.0:
                  intervals.append(cur)
              cur = [e.x0, e.x1]
              continue
          cur[1] = max(cur[1], e.x1)
      intervals.append(cur)
      return map(tuple, intervals)