An algorithm for finding a k-median in a directed tree