code: private void ensureNext() {
          // Check if the current scan result has more keys (i.e. the index did not reach the end of the result list)
          if (resultIndex < scanResult.getResult().size()) {
              return;
          }
          // Since the current scan result was fully iterated,
          // if there is another cursor scan it and ensure next key (recursively)
          if (!FIRST_CURSOR.equals(scanResult.getStringCursor())) {
              scanResult = scan(scanResult.getStringCursor(), scanParams);
              resultIndex = 0;
              ensureNext();
          }
      }
docs: Make sure the result index points to the next available key in the scan result, if exists.