class ModalStack {

    public void dismissAllModals(ViewController root, Options mergeOptions, CommandListener listener) {
        if (modals.isEmpty()) {
            listener.onError("Nothing to dismiss");
            return;
        }

        String topModalId = peek().getId();
        int modalsDismissed = size();

        peek().mergeOptions(mergeOptions);

        while (!modals.isEmpty()) {
            if (modals.size() == 1) {
                dismissModal(modals.get(0).getId(), root, new CommandListenerAdapter(listener) {
                    @Override
                    public void onSuccess(String childId) {
                        eventEmitter.emitModalDismissed(topModalId, modalsDismissed);
                        super.onSuccess(childId);
                    }
                });
            } else {
                modals.get(0).destroy();
                modals.remove(0);
            }
        }
    }

    public  ModalStack(Activity activity);
    @RestrictTo(RestrictTo.Scope.TESTS)  ModalStack(ModalPresenter presenter);

}