Find all permission sets making use of all of a list of policy_instances.
    The input is an array of policy instances.

def _policy_psets(policy_instances):
    """Find all permission sets making use of all of a list of policy_instances.
    The input is an array of policy instances.

    """
    if len(policy_instances) == 0:
        # Special case: find any permission sets that don't have
        # associated policy instances.
        return PermissionSet.objects.filter(policyinstance__isnull=True)
    else:
        return PermissionSet.objects.filter(
            policyinstance__policy__in=policy_instances).distinct()