public static <E> E uniqueElement(Collection<E> entities) throws NonUniqueResultException {
		int size = entities.size();
		if (size == 0)
			return null;
		E first = entities.iterator().next();
		for (E entity : entities) {
			if (entity != first) {
				throw new NonUniqueResultException(size);
			}
		}
		return first;
	}