private void writePoolTreeNode(RPFormatter rpFormatter) throws IOException {
      if (pool != null) {
        String path = pool.getPoolPath();
        int idx = path.lastIndexOf('.');
        if (idx != -1) {
          path = path.substring(idx + 1);
        }
        Double allocFraction = pool.getAllocFraction();
        String schedulingPolicy = pool.isSetSchedulingPolicy() ? pool.getSchedulingPolicy() : null;
        Integer parallelism = pool.getQueryParallelism();
        rpFormatter.startPool(path, "allocFraction", allocFraction,
            "schedulingPolicy", schedulingPolicy, "parallelism", parallelism);
      } else {
        rpFormatter.startPool(nonPoolName);
      }

      rpFormatter.startTriggers();
      for (WMTrigger trigger : triggers) {
        rpFormatter.formatTrigger(trigger.getTriggerName(), trigger.getActionExpression(),
            trigger.getTriggerExpression());
      }
      rpFormatter.endTriggers();

      rpFormatter.startMappings();
      for (Map.Entry<String, List<String>> mappingsOfType : mappings.entrySet()) {
        mappingsOfType.getValue().sort(String::compareTo);
        rpFormatter.formatMappingType(mappingsOfType.getKey(), mappingsOfType.getValue());
      }
      if (isDefault) {
        rpFormatter.formatMappingType("default", Lists.<String>newArrayList());
      }
      rpFormatter.endMappings();

      rpFormatter.startPools();
      for (PoolTreeNode node : children) {
        node.writePoolTreeNode(rpFormatter);
      }
      rpFormatter.endPools();
      rpFormatter.endPool();
    }
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