@Override
    public void check(Model model) {
        if (model == null)
            return;

        List<Model> secondPhaseModels = new ArrayList<>();
        deepFindAllModelsOfType(AppenderModel.class, secondPhaseModels, model);
        deepFindAllModelsOfType(LoggerModel.class, secondPhaseModels, model);
        deepFindAllModelsOfType(RootLoggerModel.class, secondPhaseModels, model);

        List<Pair<Model, Model>> nestedPairs = deepFindNestedSubModelsOfType(IfModel.class, secondPhaseModels);

        if (nestedPairs.isEmpty())
            return;

        addWarn("<if> elements cannot be nested within an <appender>, <logger> or <root> element");
        addWarn("See also " + NESTED_IF_WARNING_URL);
        for (Pair<Model, Model> pair : nestedPairs) {
            Model p = pair.first;
            int pLine = p.getLineNumber();
            Model s = pair.second;
            int sLine = s.getLineNumber();
            addWarn("Element <"+p.getTag()+"> at line " + pLine + " contains a nested <"+s.getTag()+"> element at line " +sLine);
        }
    }
@Test
    public void singleLoggerWithNestedIf() {
        ClassicTopModel topModel = new ClassicTopModel();
        Model rootLoggerModel = setupModel(new RootLoggerModel(), "root", 1);
        topModel.addSubModel(rootLoggerModel);

        Model ifModel0 = setupModel(new IfModel(), "if", 2);
        rootLoggerModel.addSubModel(ifModel0);

        Model loggerModel = setupModel(new LoggerModel(), "logger", 3);
        topModel.addSubModel(loggerModel);

        Model ifModel1 = setupModel(new IfModel(), "if", 4);
        loggerModel.addSubModel(ifModel1);

        Model appenderModel = setupModel(new LoggerModel(), "appender", 5);
        topModel.addSubModel(appenderModel);

        Model ifModel2 = setupModel(new IfModel(), "if", 6);
        appenderModel.addSubModel(ifModel2);


        inwspeChecker.check(topModel);
        StatusPrinter.print(context);
        // Element <root> at line 1 contains a nested <if> element at line 2
        String regex0 = "Element <root> at line 1 contains a nested <if> element at line 2";
        statusChecker.assertContainsMatch(Status.WARN, regex0);

        String regex1 = "Element <logger> at line 3 contains a nested <if> element at line 4";
        statusChecker.assertContainsMatch(Status.WARN, regex1);

        String regex2 = "Element <appender> at line 5 contains a nested <if> element at line 6";
        statusChecker.assertContainsMatch(Status.WARN, regex2);

    }