Write an algorithm to perform a breadth-first search (BFS) traversal on a binary tree.
Represent each node as a dictionary with val, left, and right keys, where missing children are null. Implement def bfs(root): and return a list of node values visited level by level. Return an empty list when root is null.
val, left, and right fields.null.def bfs(root):