def METHOD_NAME(hierarchy, ddr_i_seqs):
  ddr_set = set(ddr_i_seqs)
  previous = None
  intersection = None
  total_i_seqs = []
  for rg in hierarchy.residue_groups():
    if intersection:
      rc = get_selected_i_seqs(rg, [' CA ', ' N  ', ' H  '])
      total_i_seqs += rc
    rg_set = []
    for atom in rg.atoms(): rg_set.append(atom.i_seq)
    intersection = ddr_set.intersection(set(rg_set))
    if intersection:
      total_i_seqs += rg_set
      rc = get_selected_i_seqs(previous, [' CA ', ' C  ', ' O  '])
      total_i_seqs += rc
    previous = rg
  return total_i_seqs