List<ValueExpr> constraints = new ArrayList<ValueExpr>(16);
getConjunctiveConstraints(condition, constraints);
for (int i = constraints.size() - 1; i >= 0; i--) {
ValueExpr constraint = constraints.get(i);
TupleExpr right = node.getRightArg();
Set<String> filterVars = new VarFinder(constraint).getVars();
if (right.getBindingNames().containsAll(filterVars)) {
node.setRightArg(new Filter(right.clone(), constraint.clone()));
}
else {
and.addArg(constraint);
}
}