human
Can you provide a the Python code you requested given the following:
I am working on the file "Basic/BinaryTree.ipynb".
The first task is:
C++
``` c++
struct TreeNode
{
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode(int x) : val(x), left(NULL), right(NULL){}
};
```
Tree traversal
Python
Can you write Python code for it?
assistant
#Here is the Python code you requested.

class TreeNode:
    def __init__(self, val):
        self.val = val
        self.left, self.right = None, None

class Traversal(object):
    def __init__(self):
        self.traverse_path = list()
        
    def preorder(self, root):
        if root:
            self.traverse_path.append(root.val)
            self.preorder(root.left)
            self.preorder(root.right)
    
    def inorder(self, root):
        if root:
            self.inorder(root.left)
            self.traverse_path.append(root.val)
            self.inorder(root.right)
    
    def postorder(self, root):
        if root:
            self.postorder(root.left)
            self.postorder(root.right)
            self.traverse_path.append(root.val)
            
if __name__ == '__main__':
    root = TreeNode(1)
    root.left = TreeNode(2)
    root.left.left = TreeNode(3)
    root.left.right = TreeNode(4)
    root.right = TreeNode(5)
    root.right.left = TreeNode(6)
    
    traver_pre = Traversal()
    traver_pre.preorder(root)
    print traver_pre.traverse_path
    
    traver_in = Traversal()
    traver_in.inorder(root)
    print traver_in.traverse_path
    
    traver_pos = Traversal()
    traver_pos.postorder(root)
    print traver_pos.traverse_path