2
# Definition for a QuadTree node.4
def __init__(self, val, isLeaf, topLeft, topRight, bottomLeft, bottomRight):8
self.topRight = topRight9
self.bottomLeft = bottomLeft10
self.bottomRight = bottomRight15
def construct(self, grid: List[List[int]]) -> "Node":16
def is_grid_a_leaf(mylist, n):24
def tree_builder(currlist) -> "Node":27
node.isLeaf, node.val = is_grid_a_leaf(currlist, n)30
node.topLeft = node.topRight = node.bottomLeft = node.bottomRight = None33
[row[i] for i in range(n // 2)] for row in currlist[0 : n // 2]36
[row[i] for i in range(n // 2, n)] for row in currlist[0 : n // 2]39
[row[i] for i in range(n // 2)] for row in currlist[n // 2 : n]42
[row[i] for i in range(n // 2, n)] for row in currlist[n // 2 : n]44
node.topLeft = tree_builder(top_left)45
node.topRight = tree_builder(top_right)46
node.bottomLeft = tree_builder(bot_left)47
node.bottomRight = tree_builder(bot_right)50
return tree_builder(grid)