implemented breadth-first traversal of tree to correctly display hierarchy