code: public <T> T waitUntilResult(final Callable<T> function, final List<T> expectedValues) throws Exception {
  
          final List<T> actualResults = new ArrayList<>();
          int tries = 0;
          while (tries < maxTries) {
              final T result = function.call();
              if (expectedValues.contains(result)) {
                  return result;
              }
              actualResults.add(result);
              tries++;
              Utils4J.sleep(sleepMillis);
          }
          throw new IllegalStateException(
                  "Waited too long for one of the expected results: " + expectedValues + ", Actual results: " + actualResults);
  
      }
docs: Wait until one of the expected values was returned or the number of wait cycles has been exceeded. Throws
  {@link IllegalStateException} if the timeout is reached.
  
  @param function
  Function to read the value from.
  @param expectedValues
  List of values that are acceptable.
  
  @return Result.
  
  @throws Exception
  The function raised an exception.
  
  @param <T>
  Expected return type that must be an object that support equals/hasCode that is not the {@link Object}'s default method.