if (stack.empty())
document.add(currentParagraph);
else {
Element obj = stack.pop();
if (obj instanceof TextElementArray) {
TextElementArray current = (TextElementArray) obj;
current.add(currentParagraph);
}
stack.push(obj);
}
currentParagraph = null;
}