def unwrap_function(func, max_depth=10):
    """Unwraps a function that is wrapped with :func:`functools.partial()`"""
    iteration = 0
    wrapped = getattr(func, '__wrapped__', None)
    while wrapped and iteration < max_depth:
        func = wrapped
        wrapped = getattr(func, '__wrapped__', None)
        iteration += 1
    return func
