Iterator g = ca.linkedCategoryGroupIterator();
List<CategoryGroup> cg_list = ca.linkedCategoryGroupList(); Iterator g = cg_list.iterator();
	public static Set invertCGCI(Set imagesAll) {        Set cleared = new HashSet();        Set hierarchies = new HashSet();        Iterator i = imagesAll.iterator();        while (i.hasNext()) {            Image img = (Image) i.next();                        Iterator c = img.linkedCategoryIterator();            if ( ! c.hasNext() ) {                hierarchies.add(img);            } else {                while (c.hasNext()) {                    Category ca = (Category) c.next();                    if ( ! cleared.contains( ca ))                    {                        ca.clearImageLinks();                        cleared.add( ca );                    }                    ca.linkImage( img );                    Iterator g = ca.linkedCategoryGroupIterator();                    if ( ! g.hasNext() ) {                        hierarchies.add(ca);                    } else {                        while (g.hasNext()){                            CategoryGroup cg = (CategoryGroup) g.next();                                                        if ( ! cleared.contains( cg ))                            {                                cg.clearCategoryLinks();                                cleared.add( cg );                            }                            cg.linkCategory( ca );                                                        hierarchies.add( cg );                        }                    }                }            }        }		return hierarchies;	}