ClusterKey parentKey) {
if (!parentClusterGroup.getChildren().isEmpty()) {
// First pass - group the children by type.
Map<ResourceType, List<ClusterFlyweight>> childrenByType = new HashMap<ResourceType, List<ClusterFlyweight>>();
for (ClusterFlyweight child : parentClusterGroup.getChildren()) {
ClusterKeyFlyweight keyFlyweight = child.getClusterKey();
ResourceType type = this.typeMap.get(keyFlyweight.getResourceTypeId());
List<ClusterFlyweight> children = childrenByType.get(type);
if (children == null) {
children = new ArrayList<ClusterFlyweight>();
childrenByType.put(type, children);
}