private static ModalityState getSaneModalityState(ModalityState state) {
    return state != ModalityState.any() ? state : ModalityState.nonModal();
  }
private static ModalityState getSaneModalityState(ModalityState state)