@Nonnull
    public Set<Occupant> occupantsForRoomByNode(@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> local = localOccupantsByNode.getOrDefault(nodeID, Collections.emptyMap()).values().stream().flatMap(Collection::stream)
                .filter(occupant -> occupant.getRoomName().equals(roomName))
                .collect(Collectors.toSet());

            final Set<Occupant> result = new HashSet<>();
            result.addAll(local);

            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