docs: def get_trt_sources(self, optimize_same_id=None):
          """
          :returns: a list of pairs [(trt, group of sources)]
          """
          atomic = []
          acc = AccumDict(accum=[])
          for sm in self.source_models:
              for grp in sm.src_groups:
                  if grp and grp.atomic:
                      atomic.append((grp.trt, grp))
                  elif grp:
                      acc[grp.trt].extend(grp)
          if optimize_same_id is None:
              optimize_same_id = self.optimize_same_id
          if optimize_same_id is False:
              return atomic + list(acc.items())
          # extract a single source from multiple sources with the same ID
          n = 0
          tot = 0
          dic = {}
          for trt in acc:
              dic[trt] = []
              for grp in groupby(acc[trt], lambda x: x.source_id).values():
                  src = grp[0]
                  n += 1
                  tot += len(grp)
                  # src.src_group_id can be a list if get_sources_by_trt was
                  # called before
                  if len(grp) > 1 and not isinstance(src.src_group_id, list):
                      src.src_group_id = [s.src_group_id for s in grp]
                  dic[trt].append(src)
          if n < tot:
              logging.info('Reduced %d sources to %d sources with unique IDs',
                           tot, n)
          return atomic + list(dic.items())