If a new document is created programmatically, it fails with a NPE if the new document has no parent.