private TreeNode negateTree(TreeNode node) {
    if (node instanceof LeafNode) {
      // Negate leaf nodes directly
      return negateLeafNode((LeafNode) node);
    } else if (node != null) {
      // Negate logical nodes (AND/OR) recursively
      TreeNode negatedLeft = negateTree(node.getLhs());
      TreeNode negatedRight = negateTree(node.getRhs());
      LogicalOperator negatedOperator = (node.getAndOr() == LogicalOperator.AND)
              ? LogicalOperator.OR
              : LogicalOperator.AND;
      return new TreeNode(negatedLeft, negatedOperator, negatedRight);
    }
    throw new IllegalArgumentException("Unknown TreeNode type");
  }
Override the default behavior for all visit methods. This will only return a non-null result
when the context has only one child. This is done because there is no generic method to
combine the results of the context children. In all other cases null is returned.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/parser/PartFilterVisitor.java