Refactor accessing of documents, now it is possible to have different php-types of documents nested inside of other php-types