docs: def merge_items(items):
      # type: (List[AbstractType]) -> List[AbstractType]
      """Merge union items that can be merged."""
      result = []
      while items:
          item = items.pop()
          merged = None
          for i, other in enumerate(items):
              merged = merged_type(item, other)
              if merged:
                  break
          if merged:
              del items[i]
              items.append(merged)
          else:
              result.append(item)
      return list(reversed(result))