分层遍历二叉树
def level_traverse_tree(node: TreeNode):
ret = []
if node is not None:
cur = [node]
while cur:
tmp = []
next_cur = []
for item in cur:
if item:
tmp.append(item.value)
next_cur.extend([item.l_node, item.r_node])
if tmp:
ret.append(tmp)
cur = next_cur
return ret