private RelationalNode convertPlan(PlanNode planNode)
      throws TeiidComponentException, TeiidProcessingException {

    // Convert current node in planTree
    RelationalNode convertedNode = convertNode(planNode);

    if (convertedNode == null) {
      Assertion.assertTrue(planNode.getChildCount() == 1);
      return convertPlan(planNode.getFirstChild());
    }

    RelationalNode nextParent = convertedNode;

    // convertedNode may be the head of 1 or more nodes   - go to end of chain
    while (nextParent.getChildren()[0] != null) {
      nextParent = nextParent.getChildren()[0];
    }

    // Call convertPlan recursively on children
    for (PlanNode childNode : planNode.getChildren()) {
      RelationalNode child = convertPlan(childNode);
      if (planNode.getType() == NodeConstants.Types.SET_OP
          && nextParent instanceof UnionAllNode
          && childNode.getProperty(Info.SET_OPERATION) == childNode.getProperty(Info.SET_OPERATION)
          && childNode.getType() == NodeConstants.Types.SET_OP
          && childNode.hasBooleanProperty(Info.USE_ALL)) {
        for (RelationalNode grandChild : child.getChildren()) {
          if (grandChild != null) {
            nextParent.addChild(grandChild);
          }
        }
      } else {
        nextParent.addChild(child);
      }
    }

    // Return root of tree for top node
    return convertedNode;
  }