Solution to level order traversal