List<String> (Collection<? extends HgNameWithHashInfo> namesWithHashes) { //return names without duplication (actually for several heads in one branch) List<String> names = new ArrayList<>(); for (HgNameWithHashInfo hash : namesWithHashes) { if (!names.contains(hash.getName())) { names.add(hash.getName()); } } return names; }