You are given an undirected tree and are allowed to perform up to k operations on it. In each operation, you can remove a leaf vertex (a vertex connected to exactly one other vertex) and its adjacent edge. Your goal is to minimize the tree's diameter by applying these operations optimally.
The distance between two vertices is measured by the number of edges in the shortest path between them. The diameter of a tree is defined as the maximum distance between any pair of vertices in the tree.
Return the smallest possible diameter after performing at most k operations.

Hard