PsiElement[] (PsiElement element) { PsiElement psiChild = element.getFirstChild(); if (psiChild == null) return PsiElement.EMPTY_ARRAY; List<PsiElement> result = new ArrayList<>(); while (psiChild != null) { result.add(psiChild); psiChild = psiChild.getNextSibling(); } return PsiUtilCore.toPsiElementArray(result); }