Now correctly handles UniqueDocument criteria which are references to other Documents

Without this, you'll see the Mongo error 'zero-length keys are not allowed, did you use $ with double quotes?' as it doesn't know how to handle the document.