Set<Integer> (Statement stat) { HashMap<Integer, Integer> mapCount = new HashMap<>(); List<VarExprent> condlst; if (stat.getExprents() == null) { // recurse on children statements List<Integer> childVars = new ArrayList<>(); List<Exprent> currVars = new ArrayList<>(); for (Object obj : stat.getSequentialObjects()) { if (obj instanceof Statement st) { childVars.addAll(initStatement(st)); if (st.type == StatementType.DO) { DoStatement dost = (DoStatement)st; if (dost.getLoopType() != LoopType.FOR && dost.getLoopType() != LoopType.DO) { currVars.add(dost.getConditionExprent()); } } else if (st.type == StatementType.CATCH_ALL) { CatchAllStatement fin = (CatchAllStatement)st; if (fin.isFinally() && fin.getMonitor() != null) { currVars.add(fin.getMonitor()); } } } else if (obj instanceof Exprent) { currVars.add((Exprent)obj); } } // children statements for (Integer index : childVars) { Integer count = mapCount.get(index); if (count == null) { count = 0; } mapCount.put(index, count + 1); } condlst = getAllVars(currVars); } else { condlst = getAllVars(stat.getExprents()); } // this statement for (VarExprent var : condlst) { mapCount.put(var.getIndex(), 2); } HashSet<Integer> set = new HashSet<>(mapCount.keySet()); // put all variables defined in this statement into the set for (Entry<Integer, Integer> en : mapCount.entrySet()) { if (en.getValue() > 1) { mapVarDefStatements.put(en.getKey(), stat); } } mapStatementVars.put(stat.id, set); return set; }