code: public static SubMenuItem asSubMenu(MenuItem item) {
          return visitWithResult(item, new AbstractMenuItemVisitor<SubMenuItem>() {
              @Override
              public void visit(SubMenuItem item) {
                  setResult(item);
              }
  
              @Override
              public void anyItem(MenuItem item) { /* ignored */ }
          }).orElse(null);
      }
docs: Returns the menu item as a sub menu or null
  @param item the possible sub menu
  @return the sub menu, or null.