if(res instanceof Path){
Path leftPath = (Path) target;
if(ctx instanceof PredicateContextImpl){
//This will use cache for document ($) queries
PredicateContextImpl ctxi = (PredicateContextImpl) ctx;
res = ctxi.evaluate(leftPath);
} else {
Object doc = leftPath.isRootPath()?ctx.root():ctx.item();
res = leftPath.evaluate(doc, ctx.root(), ctx.configuration()).getValue();
}
}