private DownloadProcess waitForFirstSuccess() {

    // kingdom for a @tailrec!
    while (true) {
      boolean allDone = true;
      boolean allCanceled = canceled;

      for (final Map.Entry<DownloadProcess, Future<List<Result>>> entry : downloads.entrySet()) {
        final DownloadProcess download = entry.getKey();
        final Future<List<Result>> futureResult = entry.getValue();

        // if all processes are done, but none succeeded, declare failure
        final boolean done = futureResult.isDone();
        if (!done) allDone = false;

        if (allCanceled) {
          download.cancel();
          continue;
        }

        try {
          if (futureResult.isDone() && futureResult.get().get(0).success) {
            return download;
          }
          Thread.sleep(POLLING_INTERVAL);
        } catch (final Exception e) {}
      }

      if (allDone || allCanceled) {
        return null;
      }
    }
  }