def METHOD_NAME(service, environments):
    """
    Add and removes environments for selcted service.
    Args:
        service: Service
        environments: list of environment names
    Returns:
        True if service environment updated
        False if can not delete ServiceEnvironment
    """
    new_envs = []
    for env_name in environments:
        new_envs.append(Environment.objects.get_or_create(name=env_name)[0])
    current = set([e.id for e in service.environments.all()])
    new = set([e.id for e in new_envs])
    to_delete = current - new
    to_add = new - current
    for env_id in to_add:
        ServiceEnvironment.objects.create(
            service=service,
            environment_id=env_id
        )
    for env_id in to_delete:
        service_env = ServiceEnvironment.objects.get(
            service=service, environment_id=env_id
        )
        if BaseObject.objects.filter(service_env=service_env).exists():
            logger.error(
                'Can not delete service environment - it has assigned some base objects',  # noqa: E501
                extra={
                    'action_type': ACTION_TYPE,
                    'service_uid': service.uid,
                    'service_name': service.name
                }
            )
            return False
        service_env.delete()
    return True