code: private static boolean isUsingExistingAggregation(
        final Aggregation aggregation,
        final List<Aggregation> existingAggregations
    )
    {
      if (!aggregation.getAggregatorFactories().isEmpty()) {
        return false;
      }
  
      final Set<String> existingAggregationNames = existingAggregations
          .stream()
          .flatMap(xs -> xs.getAggregatorFactories().stream())
          .map(AggregatorFactory::getName)
          .collect(Collectors.toSet());
  
      return existingAggregationNames.containsAll(aggregation.getPostAggregator().getDependentFields());
    }
docs: Checks if "aggregation" is exclusively based on existing aggregations from "existingAggregations'.