code: public synchronized <T extends Renderable> Set<T> collect(Class<T> clazz) {
          Set<T> matches = new HashSet<T>();
          for (Renderable widget : widgets) {
  
              //add any matching classes to the set
              if (clazz.isInstance(widget))
                  //noinspection unchecked
                  matches.add((T) widget);
  
              //traverse down widget chains
              if (widget instanceof WidgetChain)
                  matches.addAll(widget.collect(clazz));
          }
  
          return matches;
      }
docs: This is an expensive method, never use it when live (used best at startup).
  
  @param clazz A class implementing {@code Renderable}.
  @return Returns a set of widgets that match the given type in this widget chain.