code: public void addOrUpdateItem(int parentId, MenuItem item) {
          synchronized (subMenuItems) {
              getSubMenuById(parentId).ifPresent(subMenu-> {
                  if(getMenuItems(subMenu).stream().anyMatch(it-> it.getId() == item.getId())) {
                      replaceMenuById(asSubMenu(subMenu), item);
                  }
                  else {
                      addMenuItem(asSubMenu(subMenu), item);
                  }
              });
          }
      }
docs: This will either add or update an existing item, depending if the ID is already present.
  @param parentId the parent where it should be placed / already exists
  @param item the item to either add or update.