def zigzag(root: Node | None) -> Sequence[Node | None] | list[Any]:
    if root is None:
        return []

    output: list[Sequence[Node | None]] = []

    flag = 0
    height_tree = height(root)

    for h in range(1, height_tree + 1):
        if not flag:
            output.append(get_nodes_from_left_to_right(root, h))
            flag = 1
        else:
            output.append(get_nodes_from_right_to_left(root, h))
            flag = 0

    return output