code: void removeStream(DefaultStream stream, Iterator<?> itr) {
          final boolean removed;
          if (itr == null) {
              removed = streamMap.remove(stream.id()) != null;
          } else {
              itr.remove();
              removed = true;
          }
  
          if (removed) {
              for (int i = 0; i < listeners.size(); i++) {
                  try {
                      listeners.get(i).onStreamRemoved(stream);
                  } catch (Throwable cause) {
                      logger.error("Caught Throwable from listener onStreamRemoved.", cause);
                  }
              }
  
              if (closePromise != null && isStreamMapEmpty()) {
                  closePromise.trySuccess(null);
              }
          }
      }
docs: Remove a stream from the {@link #streamMap}.
  @param stream the stream to remove.
  @param itr an iterator that may be pointing to the stream during iteration and {@link Iterator#remove()} will be
  used if non-{@code null}.