def get_environment_flags_queryset(
    environment: Environment,
    feature_name: str = None,  # type: ignore[assignment]
) -> QuerySet[FeatureState]:
    """
    Get a queryset of the latest live versions of an environments' feature states
    """
    feature_states_list = get_environment_flags_list(environment, feature_name)
    return FeatureState.objects.filter(id__in=[fs.id for fs in feature_states_list])  # type: ignore[no-any-return]

    Get a queryset of the latest live versions of an environments' feature states
    
api/features/versioning/versioning_service.py