code: private Collection<Membership> removeMembershipByUser(Session session, String userName, boolean broadcast) throws Exception
     {
        MembershipsByUserWrapper mWrapper = findMembershipsByUser(session, userName);
  
        if (broadcast)
        {
           for (Membership m : mWrapper.memberships)
           {
              preDelete(m);
           }
        }
  
        for (Node refUserNode : mWrapper.refUserNodes)
        {
           refUserNode.remove();
        }
        session.save();
  
        removeFromCache(CacheHandler.USER_PREFIX + userName);
  
        if (broadcast)
        {
           for (Membership m : mWrapper.memberships)
           {
              postDelete(m);
           }
        }
  
        return mWrapper.memberships;
     }
docs: Remove memberships entities related to current user.