5-6 lines fast python solution (48 ms)
level is a list of the nodes in the current level. Keep appending a list of the values of these nodes to ans and then updating level with all the nodes in the n
`level` is a list of the nodes in the current level. Keep appending a list of the values of these nodes to `ans` and then updating `level` with all the nodes in the next level (kids) until it reaches an empty level. Python's list comprehension makes it easier to deal with many conditions in a concise manner. \n\n<br>\nSolution 1, (6 lines)\n\n    def levelOrder(self, root):\n        ans, level = [], [root]\n        while root and level:\n            ans.append([node.val for node in level])\n            LRpair = [(node.left, node.right) for node in level]\n            level = [leaf for LR in LRpair for leaf in LR if leaf]\n        return ans\n<br>\nSolution 2, (5 lines), same idea but use only one list comprehension in while loop to get the next level\n\n    def levelOrder(self, root):\n        ans, level = [], [root]\n        while root and level:\n            ans.append([node.val for node in level])            \n            level = [kid for n in level for kid in (n.left, n.right) if kid]\n        return ans\n\n<br>\nSolution 3 (10 lines), just an expansion of solution 1&2 for better understanding.\n\n    def levelOrder(self, root):\n        if not root:\n            return []\n        ans, level = [], [root]\n        while level:\n            ans.append([node.val for node in level])\n            temp = []\n            for node in level:\n                temp.extend([node.left, node.right])\n            level = [leaf for leaf in temp if leaf]\n        return ans
['Python']