def METHOD_NAME(node):
    if not hasattr(ast, "NamedExpr"):  # python<3.8
        return False
    return (
        bool(node.body)
        and len(node.body) == 1
        and isinstance(node.body[-1].value, ast.NamedExpr)
    )