def _valid_filter(f, top=True):
    """Return True if the filter is valid.

    Parameters
    ----------
    f : dict
        The filter argument.
    top : bool
        Used to return True if the filter passed is of type dict.
        (Default value = True)

    Returns
    -------
    bool
        True if filter is valid.

    """
    if f is None:
        return True
    elif type(f) is dict:
        return all(_valid_filter(v, top=False) for v in f.values())
    elif type(f) is list:
        return not top
    else:
        return True