private TreeNode<QueryInfo> buildQueryPropertyTree(QueryImpl query, TreeNode<QueryInfo> node) {
    for (QueryImpl subQuery : query.requestedSubResources.values()) {
      ResourceDefinition childResource = subQuery.resourceDefinition;

      QueryInfo queryInfo = new QueryInfo(childResource, subQuery.requestedProperties);
      TreeNode<QueryInfo> childNode = node.addChild(queryInfo, childResource.getType().name());
      buildQueryPropertyTree(subQuery, childNode);
    }
    return node;
  }
Recursively build a tree of query information.

@param query  query to process
@param node   tree node associated with the query

@return query info tree
ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java