code: private T getWrappedPublisher(Publisher flexiblePublisher, Class<T> type) {
          if (!(flexiblePublisher instanceof FlexiblePublisher)) {
              throw new IllegalArgumentException(String.format("Publisher should be of type: '%s'. Found type: '%s'",
                  FlexiblePublisher.class, flexiblePublisher.getClass()));
          }
  
          List<ConditionalPublisher> conditions = ((FlexiblePublisher) flexiblePublisher).getPublishers();
          for (ConditionalPublisher condition : conditions) {
              if (type.isInstance(condition.getPublisher())) {
                  return type.cast(condition.getPublisher());
              }
          }
  
          return null;
      }
docs: Gets the publisher wrapped by the specofoed FlexiblePublisher.
  @param publisher                     The FlexiblePublisher wrapping the publisher.
  @param type                          The type of the publisher wrapped by the FlexiblePublisher.
  @return                              The publisher object wrapped by the FlexiblePublisher.
  Null is returned if the FlexiblePublisher does not wrap a publisher of the specified type.
  @throws IllegalArgumentException     In case publisher is not of type
  {@link org.jenkins_ci.plugins.flexible_publish.FlexiblePublisher}