private Map<String, Set<String>> mergeIdentities(
			Collection<PersonIdent> persons) {
		Map<String, Set<String>> namesToEmails = new TreeMap<String, Set<String>>(
				caseInsensitveComparator);
		namesToEmails.putAll(RepositoryUtils.mapNamesToEmails(persons));
		Map<String, Set<String>> emailsToNames = RepositoryUtils
				.mapEmailsToNames(persons);
		for (Entry<String, Set<String>> entry : emailsToNames.entrySet())
			for (String name : entry.getValue())
				namesToEmails.get(name).add(entry.getKey());

		Object[] nameEntries = namesToEmails.entrySet().toArray();
		for (int i = 0; i < nameEntries.length; i++) {
			@SuppressWarnings("unchecked")
			Entry<String, Set<String>> curr = (Entry<String, Set<String>>) nameEntries[i];
			if (curr == null)
				continue;
			for (int j = 0; j < nameEntries.length; j++) {
				if (i == j)
					continue;
				for (String email : curr.getValue().toArray(
						new String[curr.getValue().size()])) {
					@SuppressWarnings("unchecked")
					Entry<String, Set<String>> other = (Entry<String, Set<String>>) nameEntries[j];
					if (other == null)
						continue;
					if (other.getValue().contains(email)) {
						curr.getValue().addAll(other.getValue());
						namesToEmails.remove(other.getKey());
						nameEntries[j] = null;
					}
				}
			}
		}
		return namesToEmails;
	}