public SimpleDocument convertNode(Node node, String lang) throws RepositoryException {
   if (isVersionedMaster(node)) {
     return buildHistorisedDocument(node, lang);
   }
   Node parentNode = node.getParent();
   if (parentNode instanceof Version) {
     // Getting the parent node, the versionned one
     Node masterNode = getMasterNodeForVersion((Version) parentNode);
     // The historised document is built from the parent node
     HistorisedDocument document = buildHistorisedDocument(masterNode, lang);
     // Returning the version
     SimpleDocumentVersion version = document.getVersionIdentifiedBy(node.getIdentifier());
     if (version != null) {
       return new HistorisedDocumentVersion(version);
     }
     throw new PathNotFoundException(
         "Version identified by " + node.getIdentifier() + " has not been found.");
   }
   return fillDocument(node, lang);
 }