protected @Nullable Icon getElementIcon(@Iconable.IconFlags int flags) {
    PsiElement element = (PsiElement)this;
    if (!element.isValid()) {
      return null;
    }

    boolean isLocked = BitUtil.isSet(flags, ICON_FLAG_READ_STATUS) && !element.isWritable();
    int elementFlags = isLocked ? FLAGS_LOCKED : 0;

    if (element instanceof ItemPresentation) {
      Icon baseIcon = ((ItemPresentation)element).getIcon(false);
      if (baseIcon != null) {
        return IconManager.getInstance().createLayeredIcon(this, baseIcon, elementFlags);
      }
    }

    if (element instanceof PsiFileSystemItem) {
      VirtualFile file = PsiUtilCore.getVirtualFile(element);
      Icon baseIcon = null;
      if (file == null && element instanceof PsiFile) {
        baseIcon = ((PsiFile)element).getFileType().getIcon();
      }
      else if (file != null) {
        IconManager iconManager = IconManager.getInstance();
        if (iconManager instanceof CoreAwareIconManager) {
          baseIcon = ((CoreAwareIconManager)iconManager).getIcon(file, flags & ~ICON_FLAG_READ_STATUS, element.getProject());
        }
        else {
          baseIcon = isVisibilitySupported() ? getAdjustedBaseIcon(getBaseIcon(), flags) : getBaseIcon();
        }
      }
      if (baseIcon == null) return null;
      return IconManager.getInstance().createLayeredIcon(this, baseIcon, elementFlags);
    }

    return null;
  }
protected @Nullable Icon getElementIcon(@Iconable.IconFlags int flags)