Just make these iterators instead of views, e.g.:
```
val i1 = prev.partitions.iterator.map(p => currentPreferredLocations(prev, p)).filter(_.length > 0).map(s => s(0))
```
Also since `currentPreferredLocations` is only called on `prev` as the RDD, I'd make it just use that by default instead of having a parameter.