Map map = new HashMap(); Iterator i = datasets.iterator(), j; Integer id; while (i.hasNext()) { j = (((Dataset) i.next()).getImages()).iterator(); while (j.hasNext()) { id = new Integer(((Image) j.next()).getID()); map.put(id, id); } } List results = new ArrayList(); Iterator k = map.keySet().iterator(); while (k.hasNext()) results.add(k.next()); return results;
List d = new ArrayList(); d.add(dataset); return prepareListImagesID(d);
    public static List prepareListImagesID(List datasets)    {        Map map = new HashMap();        Iterator i = datasets.iterator(), j;        Integer id;        while (i.hasNext()) {            j = (((Dataset) i.next()).getImages()).iterator();            while (j.hasNext()) {                id = new Integer(((Image) j.next()).getID());                map.put(id, id);            }        }        List results = new ArrayList();        Iterator k = map.keySet().iterator();        while (k.hasNext())             results.add(k.next());        return results;    }