 	}
 
 	/// - Returns: A qualifying object for `self`. `nil` if the object is not qualified.
-	private func qualifyingObject(_ object: NSManagedObject) -> E? {
-		if let object = object as? E {
+	private func qualifyingObject(_ object: Any) -> E? {
+		if type(of: object) is E.Type {
 			if predicate.evaluate(with: object) {
-				return object
+				return (object as! E)
 			}
 		}
 		return nil

			// Search inserted objects in the context.
			let inMemoryResults = context.insertedObjects
				.flatMap { object -> E? in
					if let object = object as? E, predicate.evaluate(with: object) {
						return object
					} else {
						return nil
					}
				}

			prefetcher?.reset()

				}
			}

			if previouslyInsertedObjects.count > 0 {
				processUpdatedObjects(previouslyInsertedObjects,
				                      inserted: &insertedIds,
				                      updated: &updatedIds,
