public static <GItem> Iterator<GItem> filteredIterator(final Filter<? super GItem> filter, final Iterator<? extends GItem> iterator)
		throws NullPointerException {
		if (filter == null) throw new NullPointerException("filter = null");
		if (iterator == null) throw new NullPointerException("iterator = null");
		return new BaseIterator<GItem>() {

			Boolean has;

			GItem item;

			@Override
			public boolean hasNext() {
				if (this.has != null) return this.has.booleanValue();
				while (iterator.hasNext()) {
					if (filter.accept(this.item = iterator.next())) {
						this.has = Boolean.TRUE;
						return true;
					}
				}
				this.has = Boolean.FALSE;
				return false;
			}

			@Override
			public GItem next() {
				if (!this.hasNext()) throw new NoSuchElementException();
				this.has = null;
				return this.item;
			}

			@Override
			public void remove() {
				if (this.has != null) throw new IllegalStateException();
				iterator.remove();
			}

			@Override
			public String toString() {
				return Objects.toInvokeString("filteredIterator", filter, iterator);
			}

		};
	}