Set<BasicBlock> (Statement stat) { List<Statement> lst = new LinkedList<>(); lst.add(stat); int index = 0; do { Statement st = lst.get(index); if (st.type == StatementType.BASIC_BLOCK) { index++; } else { lst.addAll(st.getStats()); lst.remove(index); } } while (index < lst.size()); Set<BasicBlock> res = new HashSet<>(); for (Statement st : lst) { res.add(((BasicBlockStatement)st).getBlock()); } return res; }