Commit longestPath method