a little bit modification of level order traversal