def unlistify(n, depth=<NUM_LIT:1>, typ=list, get=None):
i = <NUM_LIT:0><EOL>if depth is None:<EOL><INDENT>depth = <NUM_LIT:1><EOL><DEDENT>index_desired = get or <NUM_LIT:0><EOL>while i < depth and isinstance(n, typ):<EOL><INDENT>if len(n):<EOL><INDENT>if len(n) > index_desired:<EOL><INDENT>n = n[index_desired]<EOL>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>return n<EOL><DEDENT><DEDENT>return n<EOL>
Return the desired element in a list ignoring the rest.

    >>> unlistify([1,2,3])
    1
    >>> unlistify([1,[4, 5, 6],3], get=1)
    [4, 5, 6]
    >>> unlistify([1,[4, 5, 6],3], depth=2, get=1)
    5
    >>> unlistify([1,(4, 5, 6),3], depth=2, get=1)
    (4, 5, 6)
    >>> unlistify([1,2,(4, 5, 6)], depth=2, get=2)
    (4, 5, 6)
    >>> unlistify([1,2,(4, 5, 6)], depth=2, typ=(list, tuple), get=2)
    6