Label[] () { Map<T, Label> labelsByValue = new HashMap<>(); Label[] labels = new Label[myReportingPlaces.size()]; for (int i = 0; i < myReportingPlaces.size(); i++) { labels[i] = getOrCreateLabel(labelsByValue, getSwitchedValue(myReportingPlaces.get(i))); } return labelsByValue.size() == 1 ? null : labels; }