private PsiElement[] collectPsiElements() {
    RefEntity[] refElements = myTree.getSelectedElements();
    List<PsiElement> psiElements = new ArrayList<PsiElement>();
    for (RefEntity refElement : refElements) {
      PsiElement psiElement =
          refElement instanceof RefElement ? ((RefElement) refElement).getElement() : null;
      if (psiElement != null && psiElement.isValid()) {
        psiElements.add(psiElement);
      }
    }

    return PsiUtilCore.toPsiElementArray(psiElements);
  }
 private InspectionProfile guessProfileToSelect(
     final InspectionProjectProfileManager profileManager) {
   final Set<InspectionProfile> profiles = new HashSet<InspectionProfile>();
   final RefEntity[] selectedElements = myTree.getSelectedElements();
   for (RefEntity selectedElement : selectedElements) {
     if (selectedElement instanceof RefElement) {
       final RefElement refElement = (RefElement) selectedElement;
       final PsiElement element = refElement.getElement();
       if (element != null) {
         profiles.add(profileManager.getInspectionProfile());
       }
     }
   }
   if (profiles.isEmpty()) {
     return (InspectionProfile) profileManager.getProjectProfileImpl();
   }
   return profiles.iterator().next();
 }