Given a binary tree, write a function to print it in zig-zag traversal.
Return the traversal as a list of levels, alternating left-to-right and right-to-left order. The input root is either None or a nested dictionary with keys val, left, and right; child values use the same format.
def zigzag_traversal(root):