private boolean initializePointers() { if (getRootClusters() == null) { return false; } pointersToClusterLevels = new TreeMap<>(); ArrayList<NodeCluster> outClusters = null; outClusters = new ArrayList<>(); ArrayList<NodeCluster> tempClusters = new ArrayList<>(); tempClusters.addAll(getRootClusters().values()); boolean levelFound = false; int currentLevel = 0; // first, find the highest nodecluster in the set for (NodeCluster nc : tempClusters) { if (nc.getClusterStepFormed() > currentLevel) currentLevel = nc.getClusterStepFormed(); } while (!levelFound) { if (currentLevel == 0) { levelFound = true; outClusters.addAll(tempClusters); } else { ArrayList<NodeCluster> tempClusters2 = new ArrayList<>(); tempClusters2.addAll(tempClusters); tempClusters = new ArrayList<>(); for (NodeCluster nc : tempClusters2) { // if (nc.getClusterStepParented()==maxLevel-1) // outClusters.add(nc); // else if (nc.getClusterStepFormed() < currentLevel || nc.isLeaf()) tempClusters.add(nc); else tempClusters.addAll(nc.getChildren().values()); } currentLevel--; } } return true; }