private boolean isAggregateInSelect(Node node, Collection<ASTNode> aggregateFunction) {
    if (node.getChildren() == null) {
      return false;
    }

    for (Node child : node.getChildren()) {
      if (aggregateFunction.contains(child) || isAggregateInSelect(child, aggregateFunction)) {
        return true;
      }
    }

    return false;
  }
Returns the GBY, if present;
DISTINCT, if present, will be handled when generating the SELECT.
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java