def METHOD_NAME(fn, nd=None, stack=None):
    if nd is None: nd = content
    if stack is None: stack = []
    r = fn(nd, stack)
    if r is not None:
        return r
    for ch in nd.children:
        r = METHOD_NAME(fn, ch, stack + [nd])
        if r is not None:
            return r