private Set<Comment> getComments(Collection<? extends AEntity> entities, boolean latestOnly) { Set<Comment> ret = new HashSet<Comment>(); for (AEntity entity : entities) { Set<Comment> comments = commentDao.getCommentsByParent(entity); ret.addAll(latestOnly ? getLatest(comments) : comments); } return ret; }