code: public static List<PostAggregator> pruneDependentPostAgg(List<PostAggregator> postAggregatorList, String postAggName)
    {
      ArrayList<PostAggregator> rv = new ArrayList<>();
      Set<String> deps = new HashSet<>();
      deps.add(postAggName);
      // Iterate backwards to find the last calculated aggregate and add dependent aggregator as we find dependencies
      // in reverse order
      for (PostAggregator agg : Lists.reverse(postAggregatorList)) {
        if (deps.contains(agg.getName())) {
          rv.add(agg); // add to the beginning of List
          deps.remove(agg.getName());
          deps.addAll(agg.getDependentFields());
        }
      }
  
      Collections.reverse(rv);
      return rv;
    }
docs: returns the list of dependent postAggregators that should be calculated in order to calculate given postAgg
  
  @param postAggregatorList List of postAggregator, there is a restriction that the list should be in an order such
  that all the dependencies of any given aggregator should occur before that aggregator.
  See AggregatorUtilTest.testOutOfOrderPruneDependentPostAgg for example.
  @param postAggName        name of the postAgg on which dependency is to be calculated
  
  @return the list of dependent postAggregators