private Collection<UserSessionsInfo> mergeUserSessions(
            List<List<UserSessionsInfo>> sessionsFromNodes,
            @Nullable List<UserSessionsInfo> offlineUserSessions,
            int userCount) {
        int nodeCount = sessionsFromNodes.size();
        // fast path
        if (nodeCount == 1) {
            if (offlineUserSessions == null) {
                return sessionsFromNodes.getFirst();
            } else {
                offlineUserSessions.addAll(sessionsFromNodes.getFirst());
                return offlineUserSessions;
            }
        }
        // slow path
        // A user may have multiple sessions in different nodes,
        // so we need to merge them together
        Map<Long, UserSessionsInfo> userIdToSessions =
                CollectionUtil.newMapWithExpectedSize(userCount);
        for (List<UserSessionsInfo> sessionsFromNode : sessionsFromNodes) {
            for (UserSessionsInfo sessions : sessionsFromNode) {
                userIdToSessions.compute(sessions.userId(), (userId, existing) -> {
                    if (existing == null) {
                        return sessions;
                    }
                    List<UserSessionInfo> existingSessions = existing.sessions();
                    if (CollectionUtils.isEmpty(existingSessions)) {
                        return sessions;
                    }
                    List<UserSessionInfo> newSessions = sessions.sessions();
                    if (CollectionUtils.isEmpty(newSessions)) {
                        return existing;
                    }
                    // Note that we assume existingSessions is mutable
                    existingSessions.addAll(newSessions);
                    return existing;
                });
            }
        }
        if (offlineUserSessions == null) {
            return userIdToSessions.values();
        } else {
            offlineUserSessions.addAll(userIdToSessions.values());
            return offlineUserSessions;
        }
    }
@return includes the sessions with the {@link UserStatus#OFFLINE} status for offline users
turms-service/src/main/java/im/turms/service/domain/user/service/onlineuser/SessionService.java