def _convert_nested_dict_values_to_to_sets(nested_dict):
    """
    Given a nested dictionary from kmer -> ID -> list of positions
    convert it to a dictionary from kmer -> ID -> set of positions.

    This simplifies code which wants to use these positions as a set
    against which membership is repeatedly checked.
    """
    return {
        kmer: {
            key: set(position_list)
            for (key, position_list) in id_to_positions_dict.items()}
        for (kmer, id_to_positions_dict)
        in nested_dict.items()
    }