private static void buildPoolTree(WMFullResourcePlan fullRp, PoolTreeNode root, Map<String, PoolTreeNode> poolMap) {
      for (WMPool pool : fullRp.getPools()) {
        // Create or add node for current pool.
        String path = pool.getPoolPath();
        PoolTreeNode curr = poolMap.get(path);
        if (curr == null) {
          curr = new PoolTreeNode();
          poolMap.put(path, curr);
        }
        curr.pool = pool;
        if (fullRp.getPlan().isSetDefaultPoolPath() && fullRp.getPlan().getDefaultPoolPath().equals(path)) {
          curr.isDefault = true;
        }

        // Add this node to the parent node.
        int ind = path.lastIndexOf('.');
        PoolTreeNode parent;
        if (ind == -1) {
          parent = root;
        } else {
          String parentPath = path.substring(0, ind);
          parent = poolMap.get(parentPath);
          if (parent == null) {
            parent = new PoolTreeNode();
            poolMap.put(parentPath, parent);
          }
        }
        parent.children.add(curr);
      }
    }
A n-ary tree for the pools, each node contains a pool and its children.
ql/src/java/org/apache/hadoop/hive/ql/ddl/workloadmanagement/resourceplan/show/formatter/ShowResourcePlanFormatter.java