import run_tests from r3_itree import T, Tree def preorder( tree: Optional[ Tree[ T ] ] ) \ -> Generator[ T, None, None ]: if tree is not None: yield tree.value yield from preorder( tree.left ) yield from preorder( tree.right ) def inorder( tree: Optional[ Tree[ T ] ] ) \ -> Generator[ T, None, None ]: if tree is not None: yield from inorder( tree.left ) yield tree.value yield from inorder( tree.right ) def postorder( tree: Optional[ Tree[ T ] ] ) \ -> Generator[ T, None, None ]: if tree is not None: yield from postorder( tree.left ) yield from postorder( tree.right ) yield tree.value