### Question:
AllBranchesReturn { public boolean execute(CtElement element) { ControlFlowBuilder builder = new ControlFlowBuilder(); ControlFlowGraph graph = builder.build(element); graph.simplify(); List<ControlFlowNode> exits = graph.findNodesOfKind(BranchKind.EXIT); int returnCount = 0; int incomingCount = -1; for (ControlFlowNode n : exits) { Set<ControlFlowEdge> edges = graph.incomingEdgesOf(n); incomingCount = edges.size(); for (ControlFlowEdge in : edges) { if (in.getSourceNode().getStatement() != null && in.getSourceNode().getStatement() instanceof CtReturn) { returnCount++; } } } return returnCount == incomingCount || returnCount == 0; }  boolean execute(CtElement element);  }### Answer:
@Test public void nestedIfSomeNotReturning() throws Exception { testSegment(new AbstractProcessor<CtIf>() { @Override public void process(CtIf element) { CtMethod m = element.getParent().getParent(CtMethod.class); if (m != null && m.getSimpleName().equals("nestedIfSomeNotReturning")) if (element.getCondition().toString().contains("b < 1")) { AllBranchesReturn alg = new AllBranchesReturn(); assertFalse(alg.execute(element)); } } }); }
@Test public void testNestedIfAllReturning() throws Exception { testSegment(new AbstractProcessor<CtIf>() { @Override public void process(CtIf element) { CtMethod m = element.getParent().getParent(CtMethod.class); if (m != null && m.getSimpleName().equals("nestedIfAllReturning")) if (element.getCondition().toString().contains("a > 0")) { AllBranchesReturn alg = new AllBranchesReturn(); assertTrue(alg.execute(element)); } } }); }