code: public static JoinNode reconstructJoinTreeFromSubTrees(List<JoinNode> subTrees) {
          if (subTrees == null || subTrees.isEmpty()) {
              return null;
          }
          // Reconstruct the tree. The first element is the first sub-tree and so on
          JoinNode joinNode = subTrees.get(0);
          for (int i = 1; i < subTrees.size(); ++i) {
              JoinNode nextNode = subTrees.get(i);
              boolean replaced = joinNode.replaceChild(nextNode);
              // There must be a node in the current tree to be replaced
              assert(replaced);
          }
          return joinNode;
      }
docs: Reconstruct a join tree from the list of sub-trees connecting the sub-trees in the order
  they appear in the list. The list of sub-trees must be initially obtained by calling the extractSubTrees
  method on the original tree.
  
  @param subTrees the list of sub trees.
  @return The reconstructed tree