code: SortedMap<PrimaryKey, RangeTree<PrimaryKey, AggregationChunk>> groupByPartition(int partitioningKeyLength) {
  		SortedMap<PrimaryKey, RangeTree<PrimaryKey, AggregationChunk>> partitioningKeyToTree = new TreeMap<>();
  
  		Set<AggregationChunk> allChunks = prefixRanges[0].getAll();
  		for (AggregationChunk chunk : allChunks) {
  			PrimaryKey minKeyPrefix = chunk.getMinPrimaryKey().prefix(partitioningKeyLength);
  			PrimaryKey maxKeyPrefix = chunk.getMaxPrimaryKey().prefix(partitioningKeyLength);
  
  			if (!minKeyPrefix.equals(maxKeyPrefix))
  				return null; // not partitioned
  
  			RangeTree<PrimaryKey, AggregationChunk> tree = partitioningKeyToTree.get(minKeyPrefix);
  			if (tree == null) {
  				tree = RangeTree.create();
  				partitioningKeyToTree.put(minKeyPrefix, tree);
  			}
  
  			tree.put(chunk.getMinPrimaryKey(), chunk.getMaxPrimaryKey(), chunk);
  		}
  
  		return partitioningKeyToTree;
  	}
docs: visibleForTest