Annotates tuples before JSON serialization, so that they can be
    reconstructed during deserialization. Each tuple is converted into a
    dictionary of the form:

        {'_type': 'tuple', 'items': (...)}

    This function acts recursively on lists, so that tuples nested inside a list
    (or doubly nested, triply nested, etc.) will also be annotated.

def hint_tuples(o):
    """
    Annotates tuples before JSON serialization, so that they can be
    reconstructed during deserialization. Each tuple is converted into a
    dictionary of the form:

        {'_type': 'tuple', 'items': (...)}

    This function acts recursively on lists, so that tuples nested inside a list
    (or doubly nested, triply nested, etc.) will also be annotated.
    """
    if isinstance(o, tuple):
        return dict(_type='tuple', items=o)
    elif isinstance(o, list):
        return [hint_tuples(el) for el in o]
    else:
        return o