import pickle


def identity_serialize_deserialize(thing, the_class):
    """ Take the thing, serialize it to a dict of basic types, pickle it.
    Then unpickle the result and deserialize it to the original object.
    Return the result. This whole operation should be equivalent to identity.
    It "shouldn't change" the thing.

    :param thing Serializable: the thing to test
    :param the_class type: final type of serializable
    :return the_class: the deserialized object
    """
    with open('env.pkl', 'wb') as f:
        data = thing.serialize()
        pickle.dump(data, f, protocol=pickle.HIGHEST_PROTOCOL)

    with open('env.pkl', 'rb') as f:
        serialized = pickle.load(f)

    return the_class.deserialize(serialized)