private synchronized boolean syncGroups(Object item, boolean addOrRemove) {
        boolean result = false;
        // only sync if the group list has been instantiated
        if (knownGroupNamesInList != null) {
            Group group = Group.resolveFrom(item);
            if (group != null) {
                result = true;
                if (addOrRemove == ADD) {
                    knownGroupNamesInList.add(group.getName());
                } else if (addOrRemove == REMOVE) {
                    knownGroupNamesInList.remove(group.getName());
                    if (knownGroupNamesInList.isEmpty()) {
                        knownGroupNamesInList = null;
                    }
                }
            }
        }
        return result;
    }
This method is called from several of the mutators to keep
the group set in sync with the full list. 

@param item The item to be added or removed if it is in the group set
@param addOrRemove True to add, false to remove
@return true if the given item is a group
xmppserver/src/main/java/org/jivesoftware/openfire/group/ConcurrentGroupList.java