Stack newStack = new Stack();
while (!(current instanceof Chapter
|| current instanceof Section || current instanceof Cell)) {
newStack.push(current);
if (current instanceof Anchor) {
img.setAnnotation(new Annotation(0, 0, 0,
0, ((Anchor) current).getReference()));
}
current = stack.pop();
}
((TextElementArray) current).add(img);