@Nonnull
    public Set<Occupant> occupantsForRoomExceptForNode(@Nonnull final String roomName, @Nonnull final NodeID nodeID, final boolean includeFederated)
    {
        mutex.readLock().lock();
        try {
            // TODO optimize this in a way that it does not need to iterate over all occupants.
            final Set<Occupant> result = new HashSet<>();
            for (Map.Entry<NodeID, Map<JID, Set<Occupant>>> entry : localOccupantsByNode.entrySet()) {
                if (entry.getKey().equals(nodeID)) {
                    continue;
                }
                final Map<JID, Set<Occupant>> occupantsOnRemoteNode = entry.getValue();
                for (final Set<Occupant> occupantsForJID : occupantsOnRemoteNode.values()) {
                    for (final Occupant occupantForJID : occupantsForJID) {
                        if (occupantForJID.getRoomName().equals(roomName)) {
                            result.add(occupantForJID);
                        }
                    }
                }
            }

            if (includeFederated) {
                final Set<Occupant> federated = federatedOccupants.values().stream().flatMap(Collection::stream)
                    .filter(occupant -> occupant.getRoomName().equals(roomName))
                    .collect(Collectors.toSet());
                result.addAll(federated);
            }

            return result;
        } finally {
            mutex.readLock().unlock();
        }
    }
Checks whether the occupant exists.

@param occupant The subject of the existence check
@return True if the occupant was found, otherwise false.
xmppserver/src/main/java/org/jivesoftware/openfire/muc/spi/OccupantManager.java