docs: AbstractJcrNode node( CachedNode cachedNode,
                            SessionCache cache,
                            AbstractJcrNode.Type expectedType,
                            NodeKey parentKey ) {
          assert cachedNode != null;
          NodeKey nodeKey = cachedNode.getKey();
          AbstractJcrNode node = jcrNodes.get(nodeKey);
          boolean mightBeShared = true;
          if (node == null) {
              if (expectedType == null) {
                  Name primaryType = cachedNode.getPrimaryType(cache);
                  expectedType = Type.typeForPrimaryType(primaryType);
                  if (expectedType == null) {
                      // If this node from the system workspace, then the default is Type.SYSTEM rather than Type.NODE ...
                      if (repository().systemWorkspaceKey().equals(nodeKey.getWorkspaceKey())) {
                          expectedType = Type.SYSTEM;
                      } else {
                          expectedType = Type.NODE;
                      }
                      assert expectedType != null;
                  }
              }
              // Check if the new node is in the system area ...
              if (expectedType == Type.SYSTEM || expectedType == Type.VERSION || expectedType == Type.VERSION_HISTORY) {
                  Path path = cachedNode.getPath(cache);
                  assert path.size() > 0;
                  if (!path.getSegment(0).getName().equals(JcrLexicon.SYSTEM)) {
                      // It is NOT below "/jcr:system"; someone must be using a node type normally used in the system area ...
                      expectedType = Type.NODE;
                  }
              }
              switch (expectedType) {
                  case NODE:
                      node = new JcrNode(this, nodeKey);
                      break;
                  case VERSION:
                      node = new JcrVersionNode(this, nodeKey);
                      mightBeShared = false;
                      break;
                  case VERSION_HISTORY:
                      node = new JcrVersionHistoryNode(this, nodeKey);
                      mightBeShared = false;
                      break;
                  case SYSTEM:
                      node = new JcrSystemNode(this, nodeKey);
                      mightBeShared = false;
                      break;
                  case ROOT:
                      try {
                          return getRootNode();
                      } catch (RepositoryException e) {
                          assert false : "Should never happen: " + e.getMessage();
                      }
              }
              assert node != null;
              AbstractJcrNode newNode = jcrNodes.putIfAbsent(nodeKey, node);
              if (newNode != null) {
                  // Another thread snuck in and created the node object ...
                  node = newNode;
              }
          }
  
          if (mightBeShared && parentKey != null && cachedNode.getMixinTypes(cache).contains(JcrMixLexicon.SHAREABLE)) {
              // This is a shareable node, so we have to get the proper Node instance for the given parent ...
              node = node.sharedSet().getSharedNode(cachedNode, parentKey);
          }
          return node;
      }