private static boolean is(@Nullable Icon icon, @NotNull Icon expected) {
    if (expected.equals(icon)) return true;
    if (icon instanceof CompositeIcon o) {
      for (int i = 0; i < o.getIconCount(); i++) {
        if (is(o.getIcon(i), expected)) return true;
      }
    }
    if (icon instanceof DeferredIcon o) {
      // do not calculate complex icons at this point
      return is(o.getBaseIcon(), expected);
    }
    if (icon instanceof RetrievableIcon o) {
      if (o.isComplex()) {
        return false;
      }
      if (is(o.retrieveIcon(), expected)) {
        return true;
      }
    }
    return false;
  }
private static boolean is(@Nullable Icon icon, @NotNull Icon expected)