class TransitiveTargets {

  private final CallGraph cg;
  private final Filter filter;

  public TransitiveTargets(CallGraph cg) {
    this(cg, null);
  }

  public TransitiveTargets(CallGraph cg, Filter filter) {
    this.cg = cg;
    this.filter = filter;
  }

  public Iterator<MethodOrMethodContext> iterator(Unit u) {
    ArrayList<MethodOrMethodContext> methods = new ArrayList<MethodOrMethodContext>();
    Iterator<Edge> it = cg.edgesOutOf(u);
    if (filter != null) {
      it = filter.wrap(it);
    }
    while (it.hasNext()) {
      Edge e = it.next();
      methods.add(e.getTgt());
    }
    return iterator(methods.iterator());
  }

  public Iterator<MethodOrMethodContext> iterator(MethodOrMethodContext momc) {
    ArrayList<MethodOrMethodContext> methods = new ArrayList<MethodOrMethodContext>();
    Iterator<Edge> it = cg.edgesOutOf(momc);
    if (filter != null) {
      it = filter.wrap(it);
    }
    while (it.hasNext()) {
      Edge e = it.next();
      methods.add(e.getTgt());
    }
    return iterator(methods.iterator());
  }

  public Iterator<MethodOrMethodContext> iterator(Iterator<? extends MethodOrMethodContext> methods) {
    Set<MethodOrMethodContext> s = new HashSet<MethodOrMethodContext>();
    ArrayList<MethodOrMethodContext> worklist = new ArrayList<MethodOrMethodContext>();
    while (methods.hasNext()) {
      MethodOrMethodContext method = methods.next();
      if (s.add(method)) {
        worklist.add(method);
      }
    }
    return iterator(s, worklist);
  }

  private Iterator<MethodOrMethodContext> iterator(Set<MethodOrMethodContext> s, ArrayList<MethodOrMethodContext> worklist) {<FILL_FUNCTION_BODY>}
}

    for (int i = 0, end = worklist.size(); i < end; i++) {
      MethodOrMethodContext method = worklist.get(i);
      Iterator<Edge> it = cg.edgesOutOf(method);
      if (filter != null) {
        it = filter.wrap(it);
      }
      while (it.hasNext()) {
        Edge e = it.next();
        if (s.add(e.getTgt())) {
          worklist.add(e.getTgt());
        }
      }
    }
    return worklist.iterator();
  
<no_super_class>