public static Constraint replaceReferencesToRemovedSource( QueryContext context,
Constraint constraint,
Map<SelectorName, SelectorName> rewrittenSelectors ) {
if (constraint instanceof And) {
And and = (And)constraint;
Constraint left = replaceReferencesToRemovedSource(context, and.getLeft(), rewrittenSelectors);
Constraint right = replaceReferencesToRemovedSource(context, and.getRight(), rewrittenSelectors);
if (left == and.getLeft() && right == and.getRight()) return and;
return new And(left, right);
}
if (constraint instanceof Or) {
Or or = (Or)constraint;
Constraint left = replaceReferencesToRemovedSource(context, or.getLeft(), rewrittenSelectors);
Constraint right = replaceReferencesToRemovedSource(context, or.getRight(), rewrittenSelectors);