import math


def compares_equal_with_nan(one, two):
    """
    Return True if the two objects are equal, assuming NaN == NaN.

    Objects can include lists, dictionaries, floats, integers, strings, and/or
    floats.  They can be nested.

    """
    if type(one) != type(two):
        return False
    if type(one) is dict:
        if sorted(one.keys()) != sorted(two.keys()):
            return False
        return all(compares_equal_with_nan(one[x], two[x])
                   for x in one.keys())
    elif type(one) is list:
        return (len(one) == len(two) and
                all(compares_equal_with_nan(x, y)
                    for x, y in zip(one, two)))
    else:
        # string, integer, or float
        if type(one) is float:
            return one == two or (math.isnan(one) and math.isnan(two))
        else:
            return one == two