private static PsiDirectory getParentDirectory(PsiElement element) {
    PsiFile file = InjectedLanguageManager.getInstance(element.getProject()).getTopLevelFile(element);
    if (file != null) {
      element = file.getOriginalFile();
    }
    while (element != null && !(element instanceof PsiDirectory)) {
      element = element.getParent();
    }
    return (PsiDirectory)element;
  }
private static PsiDirectory getParentDirectory(PsiElement element)