def unwrap(f):
    """Safely obtain the inner function of a previously wrapped (or decorated)
    function. This either returns ``f.__wrapped__`` or just ``f`` if the latter
    fails.

    .. |unwrap| replace:: :py:func:`unwrap`"""
    try:
        return f.__wrapped__
    except AttributeError:
        return f
