def METHOD_NAME(
    data: Mapping[str, Any], allowlist: Optional[Mapping[str, Any]]
) -> Optional[Mapping[str, Any]]:
    """
    Recursively traverses the data and only keeps values based on the allowlist.
    """
    if allowlist is None:
        return None
    stripped_data: Dict[str, Any] = {}
    for data_key, data_value in data.items():
        allowlist_for_data = allowlist.get(data_key)
        if allowlist_for_data is None:
            continue
        if isinstance(allowlist_for_data, Allow):
            allowed = allowlist_for_data
            if allowed is Allow.SIMPLE_TYPE and isinstance(data_value, (str, int, float, bool)):
                stripped_data[data_key] = data_value
            else:
                continue
        elif isinstance(data_value, Mapping):
            stripped_data[data_key] = METHOD_NAME(
                data_value, allowlist_for_data
            )
        elif isinstance(data_value, Sequence):
            stripped_data[data_key] = [
                METHOD_NAME(item, allowlist_for_data) for item in data_value
            ]
    return stripped_data