Fix the longest path tree problem solution