@Nullable public <T> T findChildByClass(Class<T> aClass) { for (PsiElement child : getChildren()) { if (aClass.isInstance(child)) return (T) child; } return null; }
@NotNull public <T> T[] findChildrenByClass(Class<T> aClass) { List<T> result = new ArrayList<T>(); for (PsiElement child : getChildren()) { if (aClass.isInstance(child)) result.add((T) child); } return result.toArray((T[]) Array.newInstance(aClass, result.size())); }