eliminate duplicate groups occurring through recursion