@Override public Iterator<Color> iterator() {
		return new Iterator<Color>() {
			private int[] cs = null;
			private boolean finalized = false;
			private int[] next_coordinates(int[] cs) {
				if (finalized)
					return null;

				if (cs == null) {
					cs = new int[]{ 0, 0 };
				} else {
					cs = cs.clone();
					if (cs[1] < ks[cs[0]] - 1) {
						// more of the same color
						cs[1]++;
						return cs;
					} else {
						// next color
						cs[1] = 0;
						cs[0]++;
					}
				}

				// next color until we get to a color for which cards are present
				while (cs[0] < Color.all.length && ks[cs[0]] == 0)
					cs[0]++;
				
				if (cs[0] >= Color.all.length) {
					finalized = true;
					return null;
				}
				return cs;
			}
			@Override public boolean hasNext() {
				return next_coordinates(cs) != null;
			}
			@Override public Color next() {
				cs = next_coordinates(cs);
				if (cs == null)
					throw new NoSuchElementException();
				return Color.all[cs[0]];
			}
			@Override public void remove() {
				throw new UnsupportedOperationException(); // YAGNI
			}
		};
	}