private void exclude() {
    final MavenArtifact artifactToExclude = mavenArtifactNode.getArtifact();
    final MavenArtifactNode oldestParent = getOldestParentMavenArtifact();

    DomFileElement domFileElement = getDomFileElement(oldestParent);

    if (domFileElement != null) {
      final MavenDomProjectModel rootElement =
          (MavenDomProjectModel) domFileElement.getRootElement();
      final MavenDomDependencies dependencies = rootElement.getDependencies();
      boolean found = false;

      for (MavenDomDependency mavenDomDependency : dependencies.getDependencies()) {
        if (isSameDependency(oldestParent.getArtifact(), mavenDomDependency)) {
          found = true;
          final MavenDomExclusions exclusions = mavenDomDependency.getExclusions();
          for (MavenDomExclusion mavenDomExclusion : exclusions.getExclusions()) {
            if (isSameDependency(artifactToExclude, mavenDomExclusion)) {
              return;
            }
          }
          createExclusion(artifactToExclude, exclusions);
          dependencyExcluded();
        }
      }
      if (!found) {
        final Notification notification =
            new Notification(
                MAVEN_HELPER_DEPENDENCY_ANALYZER_NOTIFICATION,
                "",
                "Parent dependency not found, it is probably in parent pom",
                NotificationType.WARNING);
        ApplicationManager.getApplication()
            .invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    Notifications.Bus.notify(notification, project);
                  }
                });
      }
    } else {
      final Notification notification =
          new Notification(
              MAVEN_HELPER_DEPENDENCY_ANALYZER_NOTIFICATION,
              "",
              "Pom file not found",
              NotificationType.WARNING);
      ApplicationManager.getApplication()
          .invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  Notifications.Bus.notify(notification, project);
                }
              });
    }
  }
  @NotNull
  public static MavenDomDependency createDomDependency(
      MavenDomDependencies dependencies, @Nullable Editor editor, @NotNull final MavenId id) {
    MavenDomDependency dep = createDomDependency(dependencies, editor);

    dep.getGroupId().setStringValue(id.getGroupId());
    dep.getArtifactId().setStringValue(id.getArtifactId());
    dep.getVersion().setStringValue(id.getVersion());

    return dep;
  }
  public static boolean processDependenciesInDependencyManagement(
      @NotNull MavenDomProjectModel projectDom,
      @NotNull final Processor<MavenDomDependency> processor,
      @NotNull final Project project) {

    Processor<MavenDomDependencies> managedDependenciesListProcessor =
        dependencies -> {
          SmartList<MavenDomDependency> importDependencies = null;

          for (MavenDomDependency domDependency : dependencies.getDependencies()) {
            if ("import".equals(domDependency.getScope().getRawText())) {
              if (importDependencies == null) {
                importDependencies = new SmartList<MavenDomDependency>();
              }

              importDependencies.add(domDependency);
            } else {
              if (processor.process(domDependency)) return true;
            }
          }

          if (importDependencies != null) {
            for (MavenDomDependency domDependency : importDependencies) {
              GenericDomValue<String> version = domDependency.getVersion();
              if (version.getXmlElement() != null) {
                GenericDomValueReference reference = new GenericDomValueReference(version);
                PsiElement resolve = reference.resolve();

                if (resolve instanceof XmlFile) {
                  MavenDomProjectModel dependModel =
                      MavenDomUtil.getMavenDomModel((PsiFile) resolve, MavenDomProjectModel.class);
                  if (dependModel != null) {
                    for (MavenDomDependency dep :
                        dependModel.getDependencyManagement().getDependencies().getDependencies()) {
                      if (processor.process(dep)) return true;
                    }
                  }
                }
              }
            }
          }

          return false;
        };

    Function<MavenDomProjectModelBase, MavenDomDependencies> domFunction =
        mavenDomProfile -> mavenDomProfile.getDependencyManagement().getDependencies();

    return process(projectDom, managedDependenciesListProcessor, project, domFunction, domFunction);
  }
  @Nullable
  public static MavenDomDependency searchManagingDependency(
      @NotNull final MavenDomDependency dependency, @NotNull final Project project) {
    final DependencyConflictId depId = DependencyConflictId.create(dependency);
    if (depId == null) return null;

    final MavenDomProjectModel model =
        dependency.getParentOfType(MavenDomProjectModel.class, false);
    if (model == null) return null;

    final Ref<MavenDomDependency> res = new Ref<MavenDomDependency>();

    Processor<MavenDomDependency> processor =
        dependency1 -> {
          if (depId.equals(DependencyConflictId.create(dependency1))) {
            res.set(dependency1);
            return true;
          }

          return false;
        };

    processDependenciesInDependencyManagement(model, processor, project);

    return res.get();
  }
  public static int getCollectionIndex(
      @NotNull final MavenDomDependencies dependencies, @Nullable final Editor editor) {
    if (editor != null) {
      int offset = editor.getCaretModel().getOffset();

      List<MavenDomDependency> dependencyList = dependencies.getDependencies();

      for (int i = 0; i < dependencyList.size(); i++) {
        MavenDomDependency dependency = dependencyList.get(i);
        XmlElement xmlElement = dependency.getXmlElement();

        if (xmlElement != null && xmlElement.getTextRange().getStartOffset() >= offset) {
          return i;
        }
      }
    }
    return -1;
  }
 @NotNull
 public static Set<MavenDomDependency> searchDependencyUsages(
     @NotNull final MavenDomDependency dependency) {
   final MavenDomProjectModel model =
       dependency.getParentOfType(MavenDomProjectModel.class, false);
   if (model != null) {
     DependencyConflictId dependencyId = DependencyConflictId.create(dependency);
     if (dependencyId != null) {
       return searchDependencyUsages(model, dependencyId, Collections.singleton(dependency));
     }
   }
   return Collections.emptySet();
 }
  public static void addTypeAndClassifierAndVersion(
      @NotNull InsertionContext context,
      @NotNull MavenDomDependency dependency,
      @NotNull String groupId,
      @NotNull String artifactId) {
    if (!StringUtil.isEmpty(dependency.getVersion().getStringValue())) return;

    Project project = context.getProject();

    if (!isInsideManagedDependency(dependency)) {
      MavenDomProjectModel model =
          DomUtil.<MavenDomProjectModel>getFileElement(dependency).getRootElement();
      MavenDomDependency managedDependency =
          findManagedDependency(model, project, groupId, artifactId);
      if (managedDependency != null) {
        if (dependency.getClassifier().getXmlTag() == null
            && dependency.getType().getXmlTag() == null) {
          String classifier = managedDependency.getClassifier().getRawText();
          if (StringUtil.isNotEmpty(classifier)) {
            dependency.getClassifier().setStringValue(classifier);
          }
          String type = managedDependency.getType().getRawText();
          if (StringUtil.isNotEmpty(type)) {
            dependency.getType().setStringValue(type);
          }
        }
        return;
      }
    }

    MavenProjectIndicesManager manager = MavenProjectIndicesManager.getInstance(project);

    Set<String> versions = manager.getVersions(groupId, artifactId);
    if (versions.size() == 1) {
      dependency.getVersion().setStringValue(ContainerUtil.getFirstItem(versions));
      return;
    }

    dependency.getVersion().setStringValue("");

    int versionPosition =
        dependency.getVersion().getXmlTag().getValue().getTextRange().getStartOffset();

    context.getEditor().getCaretModel().moveToOffset(versionPosition);

    if (versions.size() > 0) {
      invokeCompletion(context, CompletionType.BASIC);
    }
  }
 @Nullable
 public static MavenDomDependency searchManagingDependency(
     @NotNull final MavenDomDependency dependency) {
   return searchManagingDependency(dependency, dependency.getManager().getProject());
 }