private static int getCommentDepth(Map<Long, Comment> byId, Comment comment) { int depth = 0; while (comment != null) { depth++; comment = byId.get(comment.getParent()); } return Math.min(8, depth); }