code: def _cluster_by(end_iter, attr1, attr2, cluster_distance):
      
      ClusterInfo = namedtuple("ClusterInfo", ["chroms", "clusters", "lookup"])
      chr_clusters = {}
      chroms = []
      brends_by_id = {}
      for brend in end_iter:
          if not chr_clusters.has_key(brend.chrom1):
              chroms.append(brend.chrom1)
              chr_clusters[brend.chrom1] = ClusterTree(cluster_distance, 1)
          brends_by_id[int(brend.name)] = brend
          chr_clusters[brend.chrom1].insert(getattr(brend, attr1),
                                            getattr(brend, attr2),
                                            int(brend.name))
      return ClusterInfo(chroms, chr_clusters, brends_by_id)
docs: Cluster breakends by specified attributes.