code: public static <T> Optional<T> visitWithResult(MenuItem item, AbstractMenuItemVisitor<T> visitor) {
          item.accept(visitor);
          return visitor.getResult();
      }
docs: Visits a menu item calling the appropriate function for the type and collects the result
  that is set by calling your visitor's `setResult` method.
  @param item the item to be visited
  @param visitor the visitor that will be used
  @param <T> the return type
  @return an optional of the return type, set to empty unless setResult was called.