private TaggedImage findImage(Reference ref) {
        if (ref == null)
            return null;
        for (int i = allImages.size()-1; i >= 0; i--) {
            TaggedImage ti = (TaggedImage) allImages.get(i);
            if (ti.getReference() != null && ti.getReference().equals(ref))
                return ti;
        }
        return null;
    }