public CycList treeGather(Class cls) {
    final CycList result = new CycList();
    final Stack stack = new Stack();
    stack.push(this);
    while (!stack.empty()) {
      final Object obj = stack.pop();
      if (cls.isInstance(obj)) {
        result.add(obj);
      } else if (obj instanceof CycList) {
        CycList l = (CycList) obj;
        final Iterator iter = l.iterator();
        while (iter.hasNext()) {
          stack.push(iter.next());
        }
        if (!l.isProperList) {
          stack.push(l.getDottedElement());
        }
      }
    }
    return result;
  }