import ast


def is_method_node(node, node_to_context):
    """
    is a function def node and the immediate parent context is a class
    """
    if not isinstance(node, ast.FunctionDef):
        return False
    ctx = node_to_context.get(node, None)
    return isinstance(ctx, ast.ClassDef)