Simple Java solution. Perform in order tree traversal
public class Solution {\n    private TreeNode temp;\n    private int counter;\n    public int kthSmallest(TreeNode root, int k) {\n        counter  = 0;\n      
    public class Solution {\n    private TreeNode temp;\n    private int counter;\n    public int kthSmallest(TreeNode root, int k) {\n        counter  = 0;\n        dfs(root, k);\n        return temp.val;\n    }\n    public void dfs(TreeNode node, int k){\n        // perform in order tree traversal \n        if(node == null) return; // base case\n        dfs(node.left, k);\n        if(++counter == k) {\n            temp = node;\n            return;\n        }\n        dfs(node.right, k);\n    }\n}
[]