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

#
# 
# @param root TreeNode类 
# @return int整型一维数组
#
class Solution:
        # 前序遍历指根、左、右
    def preorderTraversal(self , root ):
        # write code here
        def dfs(cur):
            if cur is None:
                return
            res.append(cur.val)
            dfs(cur.left)
            dfs(cur.right)
        res = []
        dfs(root)
        return res