Length of the longest path in a weighted tree

hard
Length of the longest path in a weighted tree - Coding Problem | K5kC