void (final @NotNull PyIfStatement node) { myBuilder.startNode(node); PyExpression lastCondition = null; // last visited condition List<Pair<PsiElement, Instruction>> lastBranchingPoints = Collections.emptyList(); // outcoming negative edges from the last condition final List<Boolean> conditionResults = new ArrayList<>(); // visited conditions results final PyIfPart firstIfPart = node.getIfPart(); for (PyIfPart part : StreamEx.of(firstIfPart).append(node.getElifParts())) { if (part != firstIfPart) { // first `if` could not be considered as some `if` inheritor if (!ContainerUtil.exists(conditionResults, Boolean.TRUE::equals)) { // edges to `if` would be created below if there were no conditions evaluated to `True` earlier lastBranchingPoints.forEach(pair -> myBuilder.addPendingEdge(pair.getFirst(), pair.getSecond())); } myBuilder.prevInstruction = null; startConditionalNodeAndCheckGuards(part, lastCondition, false); } final Triple<PyExpression, List<Pair<PsiElement, Instruction>>, Boolean> currentPartResults = visitPyConditionalPart(part, node); lastCondition = currentPartResults.getFirst(); lastBranchingPoints = currentPartResults.getSecond(); conditionResults.add(currentPartResults.getThird()); } final PyTypeAssertionEvaluator negativeAssertionEvaluator = new PyTypeAssertionEvaluator(false); final PyExpression firstIfPartCondition = firstIfPart.getCondition(); // TODO: Add support for 'elif' if (firstIfPartCondition != null) { firstIfPartCondition.accept(negativeAssertionEvaluator); } final PyElsePart elseBranch = node.getElsePart(); if (elseBranch != null) { if (!ContainerUtil.exists(conditionResults, Boolean.TRUE::equals)) { // edges to `else` would be created below if there were no conditions evaluated to `True` earlier lastBranchingPoints.forEach(pair -> myBuilder.addPendingEdge(pair.getFirst(), pair.getSecond())); } myBuilder.prevInstruction = null; final PyStatementList statements = elseBranch.getStatementList(); startConditionalNodeAndCheckGuards(statements, lastCondition, false); InstructionBuilder.addAssertInstructions(myBuilder, negativeAssertionEvaluator); statements.accept(this); myBuilder.addPendingEdge(node, myBuilder.prevInstruction); } else if (ContainerUtil.getLastItem(conditionResults) != Boolean.TRUE) { // if last condition was evaluated to `True`, all outcoming `if` statement edges were correctly processed in the last `if` myBuilder.prevInstruction = null; final Instruction instruction = ContainerUtil.getFirstItem(InstructionBuilder.addAssertInstructions(myBuilder, negativeAssertionEvaluator)); if (instruction != null) { lastBranchingPoints.forEach(p -> myBuilder.addEdge(p.getSecond(), instruction)); } else { lastBranchingPoints.forEach(pair -> myBuilder.addPendingEdge(pair.getFirst(), pair.getSecond())); } myBuilder.addPendingEdge(node, myBuilder.prevInstruction); } }