def remove_duplicate_esp_diffs(dexlist, espdiffs, tol=0.01):
    """
    Filters and removes duplicate electrostatic potential differences from atoms
    supplied in dexlist.

    This functions first finds all values in espdiffs that are unique. Then the function
    removes espdiffs that differ from others by the tol.

    Parameters
    ----------
    dexlist : List of indexes of atoms with electrostatic potential differences to filter.

    espdiffs : List of all electrostatic potential differences for the desired system
        (see `espdiff()`).

    tol (default: 0.01): Tolerance used for removing similar values from unique
        electrostatic potential differences.

    Returns
    -------
    unique_dexes : List of atom indexes that match the filtered electrostatic potential
        differences.
    """

    #Pairing espdiff values with corresponding atom index in dexlist
    espd_dict = {}

    for i in dexlist:

        espd_dict[str(i)] = espdiffs[i]

    #Grabbing unique espdiff values
    unique_diffs = {}

    for dex, diff in espd_dict.items():

        if diff not in unique_diffs.values():

            unique_diffs[dex] = diff

    #print('Unique Electrostatic Potential Differences:')
    #print(unique_diffs.values())
    #print('')

    #Filtering out espdiffs that are differ to others within tol
    copy_unique_diffs = unique_diffs.copy()

    for dex, diff in copy_unique_diffs.items():

        counter = 0

        for diff2 in unique_diffs.values():

            if abs(diff2 - diff) < tol and abs(diff2 - diff) != 0:

                counter += 1

        if counter > 0:

            del unique_diffs[dex]

    #print('Unique Electrostatic Potential Differences WITHIN A TOLERANCE VALUE:')
    #unique_vals = [u for u in unique_diffs.values()]
    #print(unique_vals)
    #print(' ')

    unique_dexes = []

    for dex in unique_diffs:

        unique_dexes.append(int(dex))

    return unique_dexes