public int kthSmallest(TreeNode root, int k) {

        List<Integer> list = new ArrayList<>();

        inOrder(root, list);

        return list.get(k - 1);
    }
This is iterative solution with O(N) space and O(N) time.
get kth element from inorder traversal of Binary search tree.
src/problems/medium/KthSmallestElementinaBST.java