9 lines python code
class Solution(object):\n        def levelOrder(self, root):\n            if root is None: return []\n            q = [[root]]\n            for level in q:\n   
    class Solution(object):\n        def levelOrder(self, root):\n            if root is None: return []\n            q = [[root]]\n            for level in q:\n                record = []\n                for node in level:\n                    if node.left: record.append(node.left)\n                    if node.right: record.append(node.right)\n                if record: q.append(record)\n            return [[x.val for x in level] for level in q]
[]