@Nullable
  public static MavenDomPlugin searchManagingPlugin(@NotNull final MavenDomPlugin plugin) {
    final String artifactId = plugin.getArtifactId().getStringValue();
    final String groupId = plugin.getGroupId().getStringValue();
    if (artifactId == null) return null;

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

    SearchProcessor<MavenDomPlugin, MavenDomPlugins> processor =
        new SearchProcessor<MavenDomPlugin, MavenDomPlugins>() {
          @Override
          protected MavenDomPlugin find(MavenDomPlugins mavenDomPlugins) {
            if (!model.equals(mavenDomPlugins.getParentOfType(MavenDomProjectModel.class, true))) {
              for (MavenDomPlugin domPlugin : mavenDomPlugins.getPlugins()) {
                if (MavenPluginDomUtil.isPlugin(domPlugin, groupId, artifactId)) {
                  return domPlugin;
                }
              }
            }

            return null;
          }
        };

    Function<MavenDomProjectModelBase, MavenDomPlugins> domProfileFunction =
        mavenDomProfile -> mavenDomProfile.getBuild().getPluginManagement().getPlugins();

    process(
        model, processor, model.getManager().getProject(), domProfileFunction, domProfileFunction);

    return processor.myResult;
  }
  @NotNull
  public static Collection<MavenDomPlugin> searchManagedPluginUsages(
      @NotNull final MavenDomPlugin plugin) {
    String artifactId = plugin.getArtifactId().getStringValue();
    if (artifactId == null) return Collections.emptyList();

    String groupId = plugin.getGroupId().getStringValue();

    MavenDomProjectModel model = plugin.getParentOfType(MavenDomProjectModel.class, false);
    if (model == null) return Collections.emptyList();

    return searchManagedPluginUsages(model, groupId, artifactId);
  }
  @Nullable
  public static MavenDomPluginModel getMavenPluginModel(DomElement element) {
    Project project = element.getManager().getProject();

    MavenDomPlugin pluginElement = element.getParentOfType(MavenDomPlugin.class, false);
    if (pluginElement == null) return null;

    String groupId = pluginElement.getGroupId().getStringValue();
    String artifactId = pluginElement.getArtifactId().getStringValue();
    String version = pluginElement.getVersion().getStringValue();

    return getMavenPluginModel(project, groupId, artifactId, version);
  }
  public static boolean isPlugin(
      @NotNull MavenDomPlugin plugin, @Nullable String groupId, @NotNull String artifactId) {
    if (!artifactId.equals(plugin.getArtifactId().getStringValue())) return false;

    String pluginGroupId = plugin.getGroupId().getStringValue();

    if (groupId == null) {
      return pluginGroupId == null
          || (pluginGroupId.equals("org.apache.maven.plugins")
              || pluginGroupId.equals("org.codehaus.mojo"));
    }

    if (pluginGroupId == null
        && (groupId.equals("org.apache.maven.plugins") || groupId.equals("org.codehaus.mojo"))) {
      return true;
    }

    return groupId.equals(pluginGroupId);
  }