def get_wrapped(func):
    """Find the wrapped function in a chain of decorators.

    This looks for a _wraps attribute on the function, and returns the first
    one in the chain that doesn't have that attribute. Note that this requires
    decorators to set a _wraps attribute on the wrapper functions they return.
    See :func:`~with_wraps` for an easy to to augment existing decorators with
    this functionality.

    :param callable func: A function, probably created by a decorator.
    :returns: callable
    """
    while hasattr(func, '_wraps'):
        func = func._wraps
    return func