Update `serialize` method to not inlcuded empty compartments

Here's an updated PR to allow for embedded documents to not be required. This also ensures that empty compartments are not included in a serialized document.
I would enumerate arguments and document args in the docstring. This is not a generic function or override. I see it as public interface, so why not repeating them.
*please also have a look. some tests are not passing. it would be nice if you run them before pushing then it would be clear if it is ready for review