def METHOD_NAME(root_period_ids):
    family = set(root_period_ids)
    while True:
        children = set(
            IndicatorPeriod.objects.filter(
                parent_period__in=family
            ).values_list(
                'id', flat=True
            ))
        if family.union(children) == family:
            break
        family = family.union(children)
    return family