protected void getNextElement() {
        nextElement = null;
        while (true) {
            if (iterators.empty())
                // Reached the end of the whole CycList.
                return;
            Iterator iterator = (Iterator) iterators.peek();
            if (! iterator.hasNext()) {
                iterators.pop();
                // Reached the end of an embedded CycList.
                continue;
            }
            Object element = iterator.next();
            if (element.equals(CycObjectFactory.nil))
                // bypass nils.
                continue;
            if (! (element instanceof CycList)) {
                nextElement = element;
                // Found the next non-nil element.
                return;
            }
            // Iterate over the embedded CycList.
            iterators.push(((CycList) element).iterator());
        }
    }