code: private void initializeEntity(Collection<? extends TypeMetadata> types, NodeState nodeState) {
          for (TypeMetadata type : types) {
              Collection<TypeMetadata> superTypes = type.getSuperTypes();
              initializeEntity(superTypes, nodeState);
              for (MethodMetadata<?, ?> methodMetadata : type.getProperties()) {
                  if (methodMetadata instanceof AbstractRelationPropertyMethodMetadata) {
                      AbstractRelationPropertyMethodMetadata<?> relationPropertyMethodMetadata = (AbstractRelationPropertyMethodMetadata) methodMetadata;
                      RelationTypeMetadata<RelationshipMetadata<RemoteRelationshipType>> relationshipMetadata = relationPropertyMethodMetadata
                              .getRelationshipMetadata();
                      RemoteRelationshipType relationshipType = relationshipMetadata.getDatastoreMetadata().getDiscriminator();
                      RelationTypeMetadata.Direction direction = relationPropertyMethodMetadata.getDirection();
                      RemoteDirection remoteDirection;
                      switch (direction) {
                      case FROM:
                          remoteDirection = RemoteDirection.OUTGOING;
                          break;
                      case TO:
                          remoteDirection = RemoteDirection.INCOMING;
                          break;
                      default:
                          throw new XOException("Unsupported direction: " + direction);
                      }
                      if (nodeState.getRelationships(remoteDirection, relationshipType) == null) {
                          nodeState.setRelationships(remoteDirection, relationshipType, new StateTracker<>(new LinkedHashSet<>()));
                      }
                  }
              }
          }
      }
docs: Initializes all relation properties of the given node state with empty
  collections.
  
  @param types
  The types.
  @param nodeState
  The state of the entity.