private void AddNodeElements(List <StructureEntity> batch)
        {
            var nodeStructureEntities = batch.Where(x => x.IsChannelNode() && x.EntityId != _config.ChannelId);

            foreach (var structureEntity in nodeStructureEntities)
            {
                var entity = _entityService.GetEntity(structureEntity.EntityId, LoadLevel.DataOnly);

                if (_config.ChannelId == structureEntity.ParentId)
                {
                    _epiApi.MoveNodeToRootIfNeeded(entity.Id);
                }

                IntegrationLogger.Write(LogLevel.Debug, $"Trying to add channelNode {entity.Id} to Nodes");
                var currentNodeCode = _catalogCodeGenerator.GetEpiserverCode(entity);

                XElement nodeElement = _epiElementContainer.Nodes.FirstOrDefault(e => e.Element("Code")?.Value == currentNodeCode);

                int linkIndex = structureEntity.SortOrder;

                if (nodeElement == null)
                {
                    nodeElement = _catalogElementFactory.CreateNodeElement(entity, structureEntity.ParentId, linkIndex);
                    _epiElementContainer.AddNode(nodeElement, currentNodeCode);
                    IntegrationLogger.Write(LogLevel.Debug, $"Added channelNode {entity.Id} to Nodes");
                }
                else
                {
                    var parentNode = nodeElement.Element("ParentNode");
                    if (parentNode != null &&
                        parentNode.Value != _config.ChannelId.ToString(CultureInfo.InvariantCulture) &&
                        structureEntity.ParentId == _config.ChannelId)
                    {
                        parentNode.Value = _config.ChannelId.ToString(CultureInfo.InvariantCulture);
                        var sortOrderElement = nodeElement.Element("SortOrder");
                        if (sortOrderElement != null)
                        {
                            string oldSortOrder = sortOrderElement.Value;
                            sortOrderElement.Value = linkIndex.ToString(CultureInfo.InvariantCulture);
                            linkIndex = int.Parse(oldSortOrder);
                        }
                    }

                    var relationName = _catalogCodeGenerator.GetRelationName(entity.Id, structureEntity.ParentId);

                    if (_epiElementContainer.HasRelation(relationName))
                    {
                        continue;
                    }

                    var nodeRelationElement = _catalogElementFactory.CreateNodeRelation(structureEntity.ParentId, entity.Id, linkIndex);

                    _epiElementContainer.AddRelation(nodeRelationElement, relationName);

                    IntegrationLogger.Write(LogLevel.Debug, $"Adding relation to channelNode {entity.Id}");
                }
            }
        }