# 513

from utils.treeNode import TreeNode

# time: O(N)
# space: O(N)
class Solution:
    def find_bottom_left_value(self, root):
        level = [root]
        most_left = None

        while level:
            most_left = level[0].value
            new_level = []

            for node in level:
                if node.left:
                    new_level.append(node.left)
                
                if node.right:
                    new_level.append(node.right)
            
            level = new_level
        
        return most_left

one = TreeNode(1)
two = TreeNode(2)
three = TreeNode(3)
four = TreeNode(4)
five = TreeNode(5)
six = TreeNode(6)
seven = TreeNode(7)

one.left = five
five.left = three
five.right = four
one.right = two
two.right = six
# six.right = seven

print(one)
print('===========')
solution = Solution()
print(solution.find_bottom_left_value(one))