if (filter.getCondition() instanceof SameTerm) {
// SameTerm applies to the filter's argument
SameTerm sameTerm = (SameTerm)filter.getCondition();
TupleExpr filterArg = filter.getArg();
ValueExpr leftArg = sameTerm.getLeftArg();
ValueExpr rightArg = sameTerm.getRightArg();
// Verify that vars are (potentially) bound by filterArg
Set<String> bindingNames = filterArg.getBindingNames();
if (leftArg instanceof Var && !bindingNames.contains(((Var)leftArg).getName())
|| rightArg instanceof Var && !bindingNames.contains(((Var)rightArg).getName()))