code: private static <E extends Element> List<E> listFilter(Iterable<? extends Element> elements,
                                                            Set<ElementKind> targetKinds,
                                                            Class<E> clazz) {
          List<E> list = new ArrayList<E>();
          for (Element e : elements) {
              if (targetKinds.contains(e.getKind()))
                  list.add(clazz.cast(e));
          }
          return list;
      }
docs: Assumes targetKinds and E are sensible.