private void checkForPossibleAggregationOfLinks(
     UnderlayItem newItem, UnderlayItem topoStoreItem) {
   if (newItem instanceof ComputedLink && topoStoreItem instanceof ComputedLink) {
     ComputedLink newLink = (ComputedLink) newItem;
     ComputedLink topoStoreLink = (ComputedLink) topoStoreItem;
     if (scriptEngine != null) {
       if (aggregableWithScript(newItem, topoStoreItem)
           && newLink.getSrcNode().equals(topoStoreLink.getSrcNode())
           && newLink.getDstNode().equals(topoStoreLink.getDstNode())) {
         aggregateItems(newItem, topoStoreItem);
         return;
       }
     } else if (!newItem.equals(topoStoreItem)
         && matchTargetFields(newItem, topoStoreItem)
         && newLink.getSrcNode().equals(topoStoreLink.getSrcNode())
         && newLink.getDstNode().equals(topoStoreLink.getDstNode())) {
       // no previous aggregation on this link
       aggregateItems(newItem, topoStoreItem);
       return;
     }
   }
 }
 @Override
 public void processUpdatedChanges(
     YangInstanceIdentifier identifier, UnderlayItem updatedItem, String topologyId) {
   LOG.trace("Processing updatedChanges");
   for (TopologyStore ts : topoStoreProvider.getTopologyStores()) {
     if (ts.getId().equals(topologyId)) {
       LOG.debug("Updating overlay item");
       UnderlayItem underlayItem = ts.getUnderlayItems().get(identifier);
       Preconditions.checkNotNull(
           underlayItem, "Updated underlay item not found in the Topology store");
       underlayItem.setItem(updatedItem.getItem());
       if (underlayItem.getCorrelationItem() == CorrelationItemEnum.Link) {
         if (underlayItem instanceof ComputedLink && updatedItem instanceof ComputedLink) {
           ComputedLink underlayLink = (ComputedLink) underlayItem;
           ComputedLink updatedLink = (ComputedLink) updatedItem;
           if (!matchTargetFields(underlayItem, updatedItem)
               || !underlayLink.getSrcNode().equals(updatedLink.getSrcNode())
               || !underlayLink.getDstNode().equals(updatedLink.getDstNode())) {
             underlayLink.setLeafNodes(updatedLink.getLeafNodes());
             underlayLink.setSrcNode(updatedLink.getSrcNode());
             underlayLink.setDstNode(updatedLink.getDstNode());
             if (underlayItem.getOverlayItem() != null) {
               removeUnderlayItemFromOverlayItem(underlayItem);
             }
             checkForPossibleAggregationOfLinks(updatedLink, underlayLink);
           } else if (underlayItem.getOverlayItem() != null) {
             // in case that only Link value was changed
             topologyManager.updateOverlayItem(underlayItem.getOverlayItem());
           }
           break;
         }
       } else {
         // if Leaf Node was changed
         if (!matchTargetFields(underlayItem, updatedItem)) {
           underlayItem.setLeafNodes(updatedItem.getLeafNodes());
           if (underlayItem.getOverlayItem() != null) {
             removeUnderlayItemFromOverlayItem(underlayItem);
           }
           checkForPossibleAggregation(underlayItem, topologyId);
         } else if (underlayItem.getOverlayItem() != null) {
           // in case that only Node value was changed
           topologyManager.updateOverlayItem(underlayItem.getOverlayItem());
         }
         break;
       }
     }
   }
 }