Introdue ParentIdCollector that collects only if the parent ID is non null ie. if the document has a parent.

Closes #2744