hasOptimized = true;
final RewritableExpression path = (RewritableExpression) parent;
try {
// Create the pragma
final ExtensionExpression extension = new ExtensionExpression(context);
extension.addPragma(new Optimize(context, Optimize.OPTIMIZE_PRAGMA, null, false));
extension.setExpression(filtered);
// Replace the old expression with the pragma
path.replace(filtered, extension);
} catch (final XPathException e) {
LOG.warn("Failed to optimize expression: " + filtered + ": " + e.getMessage(), e);