for (Pair<Var, Var> implicitJoin : joins) {
// Which variable do we want to substitute out?
// We don't need to deal with the case of neither variable being on
// the RHS
Var lVar = implicitJoin.getLeft();
Var rVar = implicitJoin.getRight();
if (lhsVars.contains(lVar) && lhsVars.contains(rVar)) {
// Both vars are on LHS
if (rhsVars.contains(lVar) && rhsVars.contains(rVar)) {