code: def _group_by_sample_and_batch(samples):
      
      out = collections.defaultdict(list)
      for data in samples:
          out[(dd.get_sample_name(data), dd.get_align_bam(data), tuple(_get_batches(data)))].append(data)
      return [xs[0] for xs in out.values()]
docs: Group samples split by QC method back one per sample-batch.