import collections


def max_depth(root):
    """
    Get maximum depth of given tree by BFS

    :param root: root node of given binary tree
    :type root: TreeNode or None
    :return: maximum depth of given tree
    :rtype: int
    """
    # basic case
    if root is None:
        return 0

    # breadth-first traversal
    queue = collections.deque([root])
    depth = 0
    while queue:
        queue_size = len(queue)
        for i in range(queue_size):
            curr = queue.popleft()
            if curr.left is not None:
                queue.append(curr.left)
            if curr.right is not None:
                queue.append(curr.right)
        depth += 1

    return depth