code: private Map<String, Object> removeUnusedMapEntries(AtlasAttribute attribute, AtlasVertex vertex, String propertyName,
                                                         Map<String, Object> currentMap, Map<String, Object> newMap)
                                                                               throws AtlasException, AtlasBaseException {
          AtlasMapType        mapType       = (AtlasMapType) attribute.getAttributeType();
          Map<String, Object> additionalMap = new HashMap<>();
  
          for (String currentKey : currentMap.keySet()) {
              boolean shouldDeleteKey = !newMap.containsKey(currentKey);
  
              if (AtlasGraphUtilsV1.isReference(mapType.getValueType())) {
                  //Delete the edge reference if its not part of new edges created/updated
                  AtlasEdge currentEdge = (AtlasEdge)currentMap.get(currentKey);
  
                  if (!newMap.values().contains(currentEdge)) {
                      boolean deleted = deleteHandler.deleteEdgeReference(currentEdge, mapType.getValueType().getTypeCategory(), attribute.isOwnedRef(), true);
  
                      if (!deleted) {
                          additionalMap.put(currentKey, currentEdge);
                          shouldDeleteKey = false;
                      }
                  }
              }
  
              if (shouldDeleteKey) {
                  String propertyNameForKey = GraphHelper.getQualifiedNameForMapKey(propertyName, GraphHelper.encodePropertyKey(currentKey));
                  GraphHelper.setProperty(vertex, propertyNameForKey, null);
              }
          }
  
          return additionalMap;
      }
docs: Remove unused entries from map