Handle null _id in a sub-document

In an instance where one of the subdocuments in an embedded array
has a null value in the _id field, functions that rely on loop
comparisons will fail since they don't check for the field's existence
before casting to a comparable representation of that value.

This commit fixes how document `equals` works, as well as ensures
that looping comparators in `id` work as well.