&& element.getLevel() > 0 && element.getLevel() <= nodeStack.peek().getLevel()) {
nodeStack.pop();
}
if( element.isLeaf() ) {
if (nodeStack.isEmpty()) {
root.addElement(element);
} else {
// look for the node with the correct level
Node peek = nodeStack.peek();
if (element.level == 0) { // add to the root
nodeStack.firstElement().addElement(element);