private void sortChildren() {
      children.sort((PoolTreeNode p1, PoolTreeNode p2) -> {
        if (p2.pool == null) {
          return (p1.pool == null) ? 0 : -1;
        }
        if (p1.pool == null) {
          return 1;
        }
        return Double.compare(p2.pool.getAllocFraction(), p1.pool.getAllocFraction());
      });

      for (PoolTreeNode child : children) {
        child.sortChildren();
      }

      triggers.sort((WMTrigger t1, WMTrigger t2) -> t1.getTriggerName().compareTo(t2.getTriggerName()));
    }
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