from binarytree import tree


def bfs(node, target):
    queue = [node]
    while queue:
        working = queue.pop(0)
        if working.value == target:
            return True
        if working.left:
            queue.append(working.left)
        if working.right:
            queue.append(working.right)
    return False


if __name__ == '__main__':
    root = tree(height=4, is_perfect=False)
    print(root)
    target = int(input('Target: '))
    print('Result:', bfs(root, target))

0d2fc973d5b8fbfc105027a270250f4dcbe5559d
<mask token>

<mask token>


def bfs(node, target):
    queue = [node]
    while queue:
        working = queue.pop(0)
        if working.value == target:
            return True
        if working.left:
            queue.append(working.left)
        if working.right:
            queue.append(working.right)
    return False


<mask token>

<mask token>


def bfs(node, target):
    queue = [node]
    while queue:
        working = queue.pop(0)
        if working.value == target:
            return True
        if working.left:
            queue.append(working.left)
        if working.right:
            queue.append(working.right)
    return False


if __name__ == '__main__':
    root = tree(height=4, is_perfect=False)
    print(root)
    target = int(input('Target: '))
    print('Result:', bfs(root, target))

from binarytree import tree


def bfs(node, target):
    queue = [node]
    while queue:
        working = queue.pop(0)
        if working.value == target:
            return True
        if working.left:
            queue.append(working.left)
        if working.right:
            queue.append(working.right)
    return False


if __name__ == '__main__':
    root = tree(height=4, is_perfect=False)
    print(root)
    target = int(input('Target: '))
    print('Result:', bfs(root, target))
