def METHOD_NAME(m, fn):
    if isinstance(m, dict):
        return fn(m)
    assert isinstance(m, list)
    for m_element in m:
        i = fn(m_element)
        if i is not None:
            return i
    return None