public void deleteItems(List<PublishedItem> toDelete) {
        Log.trace("Deleting {} item(s)", toDelete.size());
        // Remove deleted items from the database
        for (PublishedItem item : toDelete) {
            Log.trace("Removing PublishedItem from persistence provider");
            XMPPServer.getInstance().getPubSubModule().getPersistenceProvider().removePublishedItem(item);
            if (lastPublished != null && lastPublished.getID().equals(item.getID())) {
                Log.trace("Removed item was previously the last published item. Setting last published item to null.");
                lastPublished = null;
            }
        }
        if (isNotifiedOfRetract()) {
            // Build packet to broadcast to subscribers
            Message message = new Message();
            Element event = message.addChildElement("event", "http://jabber.org/protocol/pubsub#event");
            // Send notification that items have been deleted to subscribers and parent node subscribers
            Set<NodeAffiliate> affiliatesToNotify = getAffiliatesToNotify();
            Log.trace("Built event notification stanza to broadcast notification to {} affiliate(s)", affiliatesToNotify.size());

            // TODO Use another thread for this (if # of subscribers is > X)????
            for (NodeAffiliate affiliate : affiliatesToNotify) {
                affiliate.sendDeletionNotifications(message, event, this, toDelete);
            }

            // XEP-0136 specifies that all connected resources of the owner of the PEP service should also get a notification.
            if ( getService() instanceof PEPService )
            {
                final PEPService service = (PEPService) getService();
                Element items = event.addElement("items");
                items.addAttribute("node", getUniqueIdentifier().getNodeId());
                for (PublishedItem publishedItem : toDelete) {
                    // Add retract information to the event notification
                    Element item = items.addElement("retract");
                    if (isItemRequired()) {
                        item.addAttribute("id", publishedItem.getID());
                    }

                    // Send the notification
                    final Collection<ClientSession> sessions = SessionManager.getInstance().getSessions(service.getAddress().getNode());
                    Log.trace("Also notifying {} connected resource(s) of the owner of the PEP service: {}", sessions.size(), service.getAddress());

                    for (final ClientSession session : sessions) {
                        service.sendNotification( this, message, session.getAddress() );
                    }

                    // Remove the added items information
                    event.remove(items);
                }
            }
        }
    }
Deletes the list of published items from the node. Event notifications may be sent to
subscribers for the deleted items, as well as all connected resources of the service owner,
if the service is a PEP service.<p>

When an affiliate has many subscriptions to the node, the affiliate will get a notification
for each set of items that affected the same list of subscriptions.<p>

@param toDelete list of items that were deleted from the node.
xmppserver/src/main/java/org/jivesoftware/openfire/pubsub/LeafNode.java