class Filter implements Iterator<Edge> {

  private final EdgePredicate pred;
  private Iterator<Edge> source;
  private Edge next = null;

  public Filter(EdgePredicate pred) {
    this.pred = pred;
  }

  public Iterator<Edge> wrap(Iterator<Edge> source) {
    this.source = source;
    advance();
    return this;
  }

  private void advance() {<FILL_FUNCTION_BODY>}

  @Override
  public boolean hasNext() {
    return next != null;
  }

  @Override
  public Edge next() {
    Edge ret = next;
    advance();
    return ret;
  }

  @Override
  public void remove() {
    throw new UnsupportedOperationException();
  }
}

    while (source.hasNext()) {
      next = source.next();
      if (next == null) {
    	continue;
      }
      if (pred.want(next)) {
        return;
      }
    }
    next = null;
  
<no_super_class>