List<ValueExpr> constraints = graphPattern.removeAllConstraints();
TupleExpr leftArg = parentGP.buildTupleExpr();
TupleExpr rightArg = graphPattern.buildTupleExpr();
LeftJoin leftJoin;
if (constraints.isEmpty()) {
leftJoin = new LeftJoin(leftArg, rightArg);
}
else {
ValueExpr constraint = constraints.get(0);
for (int i = 1; i < constraints.size(); i++) {
constraint = new And(constraint, constraints.get(i));
}
leftJoin = new LeftJoin(leftArg, rightArg, constraint);
}
graphPattern = parentGP;
graphPattern.clear();