4 lines using "yield from" (Python 3)


#1
class Solution:
    def preorderTraversal(self, A):
        if A is not None:
            yield A.val
            yield from self.preorderTraversal(A.left)
            yield from self.preorderTraversal(A.right)