def tuple2dict(mytuple, constructor=dict):
    """
    Turn a tuple as returned by dict2tuple back
    into a dictionary structure. The optional
    parameter "constructor" governs, what class
    is used to create the dictionary: by default,
    the standard dict class is used, but in DINGO
    we mostly use the DingoObjDict class.
    """
    result = constructor()
    for elt in mytuple:
        key, value = elt
        if type(value) == type(()):
            key_value = tuple2dict(value, constructor=constructor)
        elif type(value) == type([]):
            key_value = []
            for elt in value:
                key_value.append(tuple2dict(elt, constructor=constructor))
        else:
            key_value = value
        result[key] = key_value
    return result