def dict_sweep(d, vals=None, remove_invalid_list=False):
    """
    Remove keys whos values are ".", "-", "", "NA", "none", " "
    and remove empty dictionaries

    Args:
        d (dict): a dictionary
        vals (str or list): a string or list of strings to sweep, or None to use the default values
        remove_invalid_list (boolean): when true, will remove key for which
            list has only one value, which is part of "vals".
            Ex::

                test_dict = {'gene': [None, None], 'site': ["Intron", None], 'snp_build' : 136}

            with `remove_invalid_list == False`::

                {'gene': [None], 'site': ['Intron'], 'snp_build': 136}

            with `remove_invalid_list == True`::

                {'site': ['Intron'], 'snp_build': 136}
    """
    # set default supported vals for empty values
    vals = vals or [".", "-", "", "NA", "none", " ", "Not Available", "unknown"]
    for key, val in list(d.items()):
        if val in vals:
            del d[key]
        elif isinstance(val, list):
            if remove_invalid_list:
                val = [v for v in val if v not in vals]
                for item in val:
                    if isinstance(item, dict):
                        dict_sweep(item, vals, remove_invalid_list=remove_invalid_list)
                # if len(val) == 0:
                if not val:
                    del d[key]
                else:
                    d[key] = val
            else:
                for item in val:
                    if item in vals:
                        val.remove(item)
                    elif isinstance(item, dict):
                        dict_sweep(item, vals, remove_invalid_list=remove_invalid_list)
                # if len(val) == 0:
                if not val:
                    del d[key]
        elif isinstance(val, dict):
            dict_sweep(val, vals, remove_invalid_list=remove_invalid_list)
            # if len(val) == 0:
            if not val:
                del d[key]
    return d