if (iter != null) {
//we just want to collapse the leafs, and we are working only with the not collapsed sorted by offset.
List elements = new ArrayList(); //used to know the context
while (iter.hasNext()) {
PyProjectionAnnotation element = (PyProjectionAnnotation) iter.next();
//special case, we have none in our context
if (elements.size() == 0) {
elements.add(element);
} else {
if (isInsideLast(element, elements, model)) {
elements.add(element);
} else {
//ok, the one in the top has to be collapsed ( and this one added )
PyProjectionAnnotation top = (PyProjectionAnnotation) elements.remove(elements.size() - 1);
model.collapse(top);
elements.add(element);
}
}
}
if (elements.size() > 0) {
PyProjectionAnnotation top = (PyProjectionAnnotation) elements.remove(elements.size() - 1);
model.collapse(top);
}
}
}
}