code: def group_hydra_breakends(end_iter):
      
      cluster_distance, all_ends = _calculate_cluster_distance(end_iter)
      first_cluster = _cluster_by(all_ends, "start1", "end1", cluster_distance)
      for chrom in first_cluster.chroms:
          for _, _, brends in first_cluster.clusters[chrom].getregions():
              if len(brends) == 1:
                  yield [first_cluster.lookup[brends[0]]]
              else:
                  second_cluster = _cluster_by([first_cluster.lookup[x] for x in brends],
                                               "start2", "end2", cluster_distance)
                  for chrom2 in second_cluster.chroms:
                      for _, _, brends in second_cluster.clusters[chrom].getregions():
                          yield [second_cluster.lookup[x] for x in brends]
docs: Group together hydra breakends with overlapping ends.
  
      This provides a way to identify inversions, translocations
      and insertions present in hydra break point ends. We cluster together the
      endpoints and return together any items with closely oriented pairs.
      This helps in describing more complex rearrangement events.