docs: @SuppressWarnings("unchecked")
      public <P extends Stanza> P nextResult(long timeout) throws InterruptedException {
          throwIfCancelled();
          P res = null;
          long remainingWait = timeout;
          waitStart = System.currentTimeMillis();
          while (remainingWait > 0 && connectionException == null && !cancelled) {
              synchronized (this) {
                  res = (P) resultQueue.poll();
                  if (res != null) {
                      return res;
                  }
                  wait(remainingWait);
              }
              remainingWait = timeout - (System.currentTimeMillis() - waitStart);
          }
          return res;
      }