code: public final Node buildNode(Object entity, PersistenceDelegator pd, Object entityId, NodeState nodeState)
      {
          String nodeId = ObjectGraphUtils.getNodeId(entityId, entity.getClass());
  
          Node node = this.graph.getNode(nodeId);
  
          // If this node is already there in graph (may happen for bidirectional
          // relationship, do nothing and return null)
          // return node in case has already been traversed.
  
          if (node != null)
          {
              if (this.generator.traversedNodes.contains(node))
              {
                  return node;
              }
  
              return null;
          }
  
          node = new NodeBuilder().assignState(nodeState).buildNode(entity, pd, entityId, nodeId).node;
          this.graph.addNode(node.getNodeId(), node);
          return node;
  
      }
docs: On build node.
  
  @param entity
  entity
  @param pc
  persistence cache
  @param entityId
  entity id
  @return added node.