public Optional<IQ> processNoSuchUserCheck(IQ iq)
    {
        if (iq.isResponse()) {
            return Optional.empty();
        }

        final JID recipientJID = iq.getTo();

        if (iq.isRequest() && recipientJID != null && recipientJID.getNode() != null
            && !XMPPServer.getInstance().isRemote(recipientJID)
            && !UserManager.getInstance().isRegisteredUser(recipientJID, false)
            && !sessionManager.isAnonymousClientSession(recipientJID)
            && !UserManager.isPotentialFutureLocalUser(recipientJID) && sessionManager.getSession(recipientJID) == null
            && !(recipientJID.asBareJID().equals(iq.getFrom().asBareJID()) && sessionManager.isPreAuthenticatedSession(iq.getFrom())) // A pre-authenticated session queries the server about itself.
        )
        {
            // For an IQ stanza, the server MUST return a <service-unavailable/> stanza error to the sender.
            IQ response = IQ.createResultIQ(iq);
            response.setChildElement(iq.getChildElement().createCopy());
            response.setError(PacketError.Condition.service_unavailable);
            return Optional.of(response);
        }
        return Optional.empty();
    }
Performs the check as defined in RFC 6121 8.5.1. "No Such User":
<blockquote>If the 'to' address specifies a bare JID <localpart@domainpart> or full JID
<localpart@domainpart/resourcepart> where the domainpart of the JID matches a configured domain that is serviced
by the server itself, the server MUST proceed as follows. [...] If the user account identified by the 'to'
attribute does not exist, how the stanza is processed depends on the stanza type. [...] For an IQ stanza, the
server MUST return a <service-unavailable/> stanza error to the sender.</blockquote>

@see <a href="http://xmpp.org/rfcs/rfc6121.html#rules-localpart-nosuchuser">RFC 6121 8.5.1. "No Such User"</a>
xmppserver/src/main/java/org/jivesoftware/openfire/handler/IQHandler.java