code: public static MenuItem getMenuItem(@NonNull Toolbar toolbar, @IdRes int menuId) {
          View v;
          int childCount;
          View innerView;
          MenuItem menuItem;
          for (int i = 0; i < toolbar.getChildCount(); i++) {
              v = toolbar.getChildAt(i);
              if (v instanceof ActionMenuView) {
                  childCount = ((ActionMenuView) v).getChildCount();
                  for (int j = 0; j < childCount; j++) {
                      innerView = ((ActionMenuView) v).getChildAt(j);
                      if (innerView instanceof ActionMenuItemView) {
                          menuItem = ((ActionMenuItemView) innerView).getItemData();
                          if (menuItem.getItemId() == menuId) {
                              return menuItem;
                          }
                      }
                  }
              }
          }
          return null;
      }
docs: Search for a particular menu
  
  @param toolbar
  @param menuId
  @return the corresponding MenuItem, or null if not found