code: private void removeMemberships(Node userNode, boolean broadcast) throws RepositoryException
     {
        PropertyIterator refUserProps = userNode.getReferences();
        while (refUserProps.hasNext())
        {
           Node refUserNode = refUserProps.nextProperty().getParent();
           refUserNode.remove();
        }
     }
docs: Removes membership entities related to current user.