✅ One Line Solution
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)Code #1 - One LineTime complexity: O(n2). Space comp
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)

# Code #1 - One Line
Time complexity: $$O(n^2)$$. Space complexity: $$O(n)$$.
```python3
class Solution:
    def kthSmallest(self, r: Optional[TreeNode], k: int) -> int:
        return (f:=lambda n:n and f(n.left)+[n.val]+f(n.right) or [])(r)[k-1]
```

# Code #2 - Regular Solution on Stack
Time complexity: $$O(n)$$. Space complexity: $$O(n)$$.
```python3
class Solution:
    def kthSmallest(self, root: Optional[TreeNode], k: int) -> int:
        stack, node = [], root
        while True:
            while node:
                stack.append(node)
                node = node.left

            node = stack.pop()
            k -= 1
            if k == 0:
                return node.val
        
            node = node.right
```
['Stack', 'Tree', 'Depth-First Search', 'Binary Search Tree', 'Recursion', 'Binary Tree', 'Python', 'Python3']