identify_subsets function

Internal function to identify sub-sets of data and return a list with IDs.