docs: @SuppressWarnings("unchecked")
    public static <E> E[] filter(E[] elems, Filter<E> filter) {
      List<E> filtered = new ArrayList<E>();
      for (E elem: elems) {
        if (filter.accept(elem)) {
          filtered.add(elem);
        }
      }
      return (filtered.toArray((E[]) Array.newInstance(elems.getClass().getComponentType(), filtered.size())));
    }