private void resolveInstallByDependency() {
    // resolve dependencies
    boolean hasModifications = true;
    while (hasModifications) {
      log.debug("Check install dependencies: " + additions);
      hasModifications = false;
      for (Plugin plugin : additions) {
        for (String pluginID : plugin.getDepends()) {
          Plugin depend = getPluginByID(pluginID);

          if (!depend.isInstalled() || deletions.contains(depend)) {
            if (!additions.contains(depend)) {
              log.debug("Add to install: " + depend);
              additions.add(depend);
              hasModifications = true;
            }
          }
        }

        if (hasModifications) {
          break; // prevent ConcurrentModificationException
        }
      }
    }
  }
 private Set<Plugin> getDependants(Plugin plugin) {
   Set<Plugin> res = new HashSet<>();
   for (Plugin pAll : allPlugins.keySet()) {
     for (String depID : pAll.getDepends()) {
       if (depID.equals(plugin.getID())) {
         res.add(pAll);
       }
     }
   }
   return res;
 }