def to_type(obj, new_type):
    """
    Helper funciton that receives an object or a dict and convert it to a new given type.

    :param object|dict o: The object to convert
    :param Type new_type: The type to convert to.
    """
    if new_type == type(obj):
        return obj
    return new_type(**obj)
