// if (parents==null||previous==null){
// System.out.println("null");
// }
if (gnode.getLevel()==1){
localList.add(gnode);
parents.clear();
}else{
if (previous.getLevel()<gnode.getLevel()){
parents.push(previous);
}else if (previous.getLevel()>=gnode.getLevel()){
while (parents.size()>=gnode.getLevel()) parents.pop();