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

        if (index == 0) {
            while (source.hasNext()) {
                next = source.next();
                if (set.add(next)) {
                    hasNext = true;
                    return true;
                }
            }
            index++;
        }
        if (index == 1) {
            while (second.hasNext()) {
                next = second.next();
                if (set.add(next)) {
                    hasNext = true;
                    return true;
                }
            }
            index++;
        }
        hasNext = false;
        return false;
    }