Function pruneLinkedDocumentsToReferences

Recursively reduces nested named nodes (objects with @id ≠ rootEntityIRI) to reference objects { "@id": "..." } so linked documents are not carried as expanded graphs.