class StatisticsService {

	public  static Collection<Statistics> aggregateHistoricalStatistics(List<List<Statistics>> statisticsLists){
		
		if(statisticsLists.isEmpty()) return Collections.emptyList();
		
		if(statisticsLists.size()==1){
			return statisticsLists.iterator().next();
		}
		
		//TODO check if the lists have the same size
		
		//map statistics of the different organizations
		List<Statistics> aggregatedStatistics = new ArrayList<>();
		int numberOfRecords = statisticsLists.get(0).size(); //assuming that all organizations have the same amount of records
		
		List<Statistics> unaggregatedStatistics;
		
		for (int i=0; i<numberOfRecords; i++){
			unaggregatedStatistics  = new ArrayList<>();
			for (List<Statistics> orgStats : statisticsLists){
				
				if(orgStats.isEmpty()) continue;
				
				//FIXME figure out how to map the records
				//for now just use the order
				unaggregatedStatistics.add(orgStats.get(i));
			}
			
			Statistics aggregatedRecord = aggregateStatistics(unaggregatedStatistics);
			
			aggregatedStatistics.add(aggregatedRecord);
		}

		return aggregatedStatistics;
	}

}