public Set<NodeAffiliate> getAffiliatesToNotify() {
        Log.trace("Getting affiliates to notify...");

        Set<NodeAffiliate> affiliatesToNotify = new HashSet<>(affiliates);
        Log.trace("... found {} direct affiliate(s)", affiliates.size());

        // Get affiliates that are subscribed to a parent in the hierarchy of parent nodes
        for (CollectionNode parentNode : getParents()) {
            Set<NodeAffiliate> parentAffiliates = new HashSet<>();
            for (NodeSubscription subscription : parentNode.getSubscriptions()) {
                // OF-2365: Prevent sending notifications to subscribers that are not allowed to access this node.
                if (parentNode.getAccessModel().canAccessItems(this, subscription.getOwner(), subscription.getJID() )
                    && accessModel.canAccessItems(this, subscription.getOwner(), subscription.getJID()))
                {
                    parentAffiliates.add(subscription.getAffiliate());
                }
            }
            Log.trace("... found {} applicable affiliate(s) in parent node {}", parentAffiliates.size(), parentNode.getNodeID());
            affiliatesToNotify.addAll(parentAffiliates);
        }

        // XEP-0136 specifies that all connected resources of the owner of the PEP service should also get a notification (pending filtering)
        // To ensure that happens, the affiliate that represents the owner of the PEP server is added here, if it's not already present.
        if (getService() instanceof PEPService && affiliatesToNotify.stream().noneMatch( a -> a.getAffiliation().equals(NodeAffiliate.Affiliation.owner))) {
            final NodeAffiliate owner = getService().getRootCollectionNode().getAffiliate( getService().getAddress() );
            Log.trace("... added owner of the PEP service");
            affiliatesToNotify.add(owner);
        }
        Log.trace("In total {} unique affiliate(s) were identified.", affiliatesToNotify.size());
        return affiliatesToNotify;
    }
Retrieves the collection of affiliates that should be sent notifications upon changes to this node.

@return A list of node affiliates. Possibly empty.
xmppserver/src/main/java/org/jivesoftware/openfire/pubsub/LeafNode.java