private static boolean hasChildPackages(Object item) {
    PsiElement itemElement = null;
    if (item instanceof PsiElement) {
      itemElement = (PsiElement) item;
    }
    else if (item instanceof LookupElement lookupElement) {
      final PsiElement element = lookupElement.getPsiElement();
      if (element != null) {
        itemElement = element;
      }
    }
    return !(itemElement instanceof PsiFile);  // TODO deeper check?
  }
private static boolean hasChildPackages(Object item)