Given a tree T ؍ (V, E), with ͦVͦ ؍ n, we consider the problem of selecting a subtree with at most k leaves and with a diameter of at most l which minimizes the sum of the distances of the vertices from the selected subtree. We call such a subtree the (k, l)-core of T. We provide two algorithms; the first one for unweighted trees has time complexity of O(n 2 ), whereas the second one for weighted trees has time complexity of O(n 2 log n). The idea for both the algorithms is that, by starting from the tree T, we construct new rooted trees where the maximum length of a path is at most l. Then, for each new tree, we can apply a greedy-type procedure to find a subtree containing the root with at most k leaves and which minimizes the sum of the distances.