Refactor `findPaths`.