Fix the duplicate paths detection. You need to use set().