Avoid dropping recently published photos from collections

A bug in the collections API (https://github.com/500px/api-documentation/issues/83) means the plugin will sometimes remove recently published photos from collections if you immediately do something else like publish more photos or delete photos from the same collection. The solution here works by scanning the photos marked as already published locally and adding them to the list of photos in the collection returned by the API.

The downside is that this would re-add any photos to the collection that a user had manually removed through the web interface. To me that seems ok, it means that publishing a collection in Lightroom makes the remote collection match what you see locally in Lightroom but I can understand if that might be surprising to some. I'm not seeing an obvious other solution that doesn't involve fixes to the API though.
Will this fail if the photo being tested is the first or last in the photoList?