/*
public class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;

    public TreeNode(int val) {
        this.val = val;

    }

}
*/
public class Solution {
    private int num = 0;
    // 采用中序遍历,同时设置一个计数器,当num == k时,就是返回值。
    TreeNode KthNode(TreeNode pRoot, int k) { 
        if (pRoot == null) {
            return null;
        }
        TreeNode node = KthNode(pRoot.left, k);
        num++;
        if (num == k) {
            return pRoot;
        }
        System.out.println(pRoot);
        TreeNode node1 = KthNode(pRoot.right, k);
        return node == null ? node1 : node;
    }


}