public static Snapshot findLatestValidSnapshot(
      Table table, long currentSnapshotId, Predicate<Snapshot> condition) {
    Long snapshotId = currentSnapshotId;
    while (true) {
      if (snapshotId == null || table.snapshot(snapshotId) == null) {
        return null;
      }
      Snapshot snapshot = table.snapshot(snapshotId);
      if (condition.test(snapshot)) {
        return snapshot;
      } else {
        // seek parent snapshot
        snapshotId = snapshot.parentId();
      }
    }
  }
Find the latest valid snapshot which satisfies the condition.

@param table - Iceberg table
@param currentSnapshotId - find from this snapshot
@param condition - the condition to satisfy
@return the latest valid snapshot or null if not exists
amoro-format-iceberg/src/main/java/org/apache/amoro/utils/MixedTableUtil.java