Print Shortest Path Leetcode Python