import random


def _get_new_parents(current_animal_names, previous_parent_sets, num_parents):
    """Return a set of `num_parents` parent names that is not present in `previous_parent_sets`."""
    while True:
        new_parent_names = frozenset(random.sample(current_animal_names, num_parents))  # nosec
        # Duplicating a set of parents could result in Animals with the same names.
        # This would invalidate unique selection of Animals by name.
        if new_parent_names not in previous_parent_sets:
            return new_parent_names