Refactor "unique paths".