'Return the callback. If the callback is a decorated function, try to
recover the original function.'

def get_undecorated_callback(self):

    func = self.callback
    func = getattr(func, ('__func__' if py3k else 'im_func'), func)
    closure_attr = ('__closure__' if py3k else 'func_closure')
    while (hasattr(func, closure_attr) and getattr(func, closure_attr)):
        attributes = getattr(func, closure_attr)
        func = attributes[0].cell_contents
        if (not isinstance(func, FunctionType)):
            func = filter((lambda x: isinstance(x, FunctionType)), map((lambda x: x.cell_contents), attributes))
            func = list(func)[0]
    return func
