/**
  * Creates new overlay item or adds new underlay item into existing overlay item if the condition
  * for correlation is satisfied
  *
  * @param newItem - new underlay item on which the correlation is created
  */
 private void checkForPossibleAggregation(UnderlayItem newItem, String topologyId) {
   for (TopologyStore ts : topoStoreProvider.getTopologyStores()) {
     if ((!ts.getId().equals(topologyId)) || ts.isAggregateInside()) {
       for (Entry<YangInstanceIdentifier, UnderlayItem> topoStoreEntry :
           ts.getUnderlayItems().entrySet()) {
         UnderlayItem topoStoreItem = topoStoreEntry.getValue();
         if (newItem.getCorrelationItem() == CorrelationItemEnum.Link) {
           checkForPossibleAggregationOfLinks(newItem, topoStoreItem);
         } else {
           if (scriptEngine != null) {
             if (aggregableWithScript(newItem, topoStoreItem)) {
               aggregateItems(newItem, topoStoreItem);
               return;
             }
           } else if (!newItem.equals(topoStoreItem)
               && matchTargetFields(newItem, topoStoreItem)) {
             // no previous aggregation on this node
             aggregateItems(newItem, topoStoreItem);
             return;
           }
         }
       }
     }
   }
   if (wrapSingleItem()) {
     List<UnderlayItem> itemsToAggregate = new ArrayList<>();
     itemsToAggregate.add(newItem);
     OverlayItem overlayItem = new OverlayItem(itemsToAggregate, newItem.getCorrelationItem());
     newItem.setOverlayItem(overlayItem);
     topologyManager.addOverlayItem(overlayItem);
   }
 }
 /**
  * @param newItem item received from notification
  * @param topoStoreItem item already stored in topostore
  */
 private void aggregateItems(UnderlayItem newItem, UnderlayItem topoStoreItem) {
   if (topoStoreItem.getOverlayItem() == null) {
     LOG.debug("Creating new Logical Node");
     // create new logical node
     List<UnderlayItem> nodesToAggregate = new ArrayList<>();
     nodesToAggregate.add(newItem);
     nodesToAggregate.add(topoStoreItem);
     OverlayItem overlayItem =
         new OverlayItem(nodesToAggregate, topoStoreItem.getCorrelationItem());
     topoStoreItem.setOverlayItem(overlayItem);
     newItem.setOverlayItem(overlayItem);
     topologyManager.addOverlayItem(overlayItem);
     return;
   }
   LOG.debug("Adding physical node to existing Logical Node");
   // add new physical node into existing logical node
   OverlayItem overlayItem = topoStoreItem.getOverlayItem();
   newItem.setOverlayItem(overlayItem);
   overlayItem.addUnderlayItem(newItem);
   topologyManager.updateOverlayItem(overlayItem);
 }