private static void sortTriggers(WMFullResourcePlan fullRp, Map<String, PoolTreeNode> poolMap,
        Map<String, WMTrigger> triggerMap, List<WMTrigger> unmanagedTriggers, Set<WMTrigger> unusedTriggers) {
      if (fullRp.isSetTriggers()) {
        for (WMTrigger trigger : fullRp.getTriggers()) {
          triggerMap.put(trigger.getTriggerName(), trigger);
          if (trigger.isIsInUnmanaged()) {
            unmanagedTriggers.add(trigger);
          } else {
            unusedTriggers.add(trigger);
          }
        }
      }
      if (fullRp.isSetPoolTriggers()) {
        for (WMPoolTrigger pool2Trigger : fullRp.getPoolTriggers()) {
          PoolTreeNode node = poolMap.get(pool2Trigger.getPool());
          WMTrigger trigger = triggerMap.get(pool2Trigger.getTrigger());
          if (node == null || trigger == null) {
            throw new IllegalStateException("Invalid trigger to pool: " + pool2Trigger.getPool() +
                ", " + pool2Trigger.getTrigger());
          }
          unusedTriggers.remove(trigger);
          node.triggers.add(trigger);
        }
      }
    }
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