De-duplicate handleDeletedRecords() implementations
Do not skip in case the last record has been deleted

The returned list of records (mostly ids) should not be null anyways
since an empty list will be returned in case of no results.
Use maxDoc() to actually iterate over all documents

At least for older versions of lucene, numDocs() actually returns the
number of currently *alive* documents in the index, while leaving aside
all the deleted ones. This means when iterating using that number as the
index, we will stop too early!

See also this bugreport: https://issues.apache.org/jira/browse/LUCENE-2809