Fix embedded memberships in joined documents

When using the ?embed parameter to specify joins the joined documents
weren't getting their memberships added.

This change uses 'getValue', which in turn calls the mpath module to get
an array of models based on the populated path. This can also be an
array of arrays if the document is nested more than one layer deep, so
we flatten the array before processing to normalize it.