Given a binary search tree with n nodes and a real target t, return k node values whose distances to t are smallest. Implement an algorithm with O(log n + k) expected time and O(h) extra space (h is tree height), using predecessor and successor iterators (e.g., two in-order stacks) or a recursive approach. Specify tie-breaking rules, handle k > n and duplicate values, and analyze correctness and complexity. Discuss how you would adapt the solution if the structure were a general binary tree (not a BST).