* branches that are needed.
*/
protected PlanNode fillSideBranches(PlanNode input,
TableGroupJoinNode leafTable,
TableGroupJoinNode rootTable) {
TableGroupJoinNode branchTable = leafTable;
while (branchTable != rootTable) {
TableGroupJoinNode parent = branchTable.getParent();
if (isBranchpoint(parent)) {
List<PlanNode> subplans = new ArrayList<>(2);
subplans.add(input);
for (TableGroupJoinNode sibling = parent.getFirstChild();
sibling != null; sibling = sibling.getNextSibling()) {
if ((sibling == branchTable) ||
(leafLeftMostPending(sibling) == null))
continue;
List<TableSource> tables = new ArrayList<>();
PlanNode subplan = new BranchLookup(null, // no input means _Nested.
parent.getTable().getTable(),
sibling.getTable().getTable(),
tables);
subplan = fillBranch(subplan, tables, sibling, parent, sibling);
if (subplans == null)
subplans = new ArrayList<>();
subplans.add(subplan);
}
if (subplans.size() > 1)
input = new Product(parent.getTable().getTable(), subplans);
}
branchTable = parent;
}
return input;
}