import ast


def compile_single_node(node, filename):
    """Compile a 'single' ast.node (expression or statement)."""
    mode = 'eval' if isinstance(node, ast.Expr) else 'exec'
    if mode == 'eval':
        root = ast.Expression(node.value)
    else:
        root = ast.Module([node])
    return (compile(root, filename, mode), mode)