code: public static Optional<MeteredOutputStream> findWrappedMeteredOutputStream(OutputStream os) {
      if (os instanceof FilterOutputStream) {
        try {
          Optional<MeteredOutputStream> meteredOutputStream =
              findWrappedMeteredOutputStream(FilterStreamUnpacker.unpackFilterOutputStream((FilterOutputStream) os));
          if (meteredOutputStream.isPresent()) {
            return meteredOutputStream;
          }
        } catch (IllegalAccessException iae) {
          log.warn("Cannot unpack input stream due to SecurityManager.", iae);
          // Do nothing, we can't unpack the FilterInputStream due to security restrictions
        }
      }
      if (os instanceof MeteredOutputStream) {
        return Optional.of((MeteredOutputStream) os);
      }
      return Optional.absent();
    }
docs: Find the lowest {@link MeteredOutputStream} in a chain of {@link FilterOutputStream}s.