def filter_keys(d, key_whitelist):
    """
    Removes keys from a dictionary that are not
    in the provided whitelist.

    Args:
        d: The dictionary to update.
        key_whitelist: The list of allowed keys.
    
    Returns:
        The updated dictionary.
    """
    for key in d.keys():
        if key not in key_whitelist:
            d.pop(key)

    return d