private VersionConstraint checkExistingPlanNode(
      ExtensionDependency extensionDependency,
      String namespace,
      List<ModifableExtensionPlanNode> parentBranch,
      VersionConstraint previousVersionConstraint)
      throws InstallException {
    VersionConstraint versionConstraint = previousVersionConstraint;

    ModifableExtensionPlanNode existingNode =
        getExtensionNode(extensionDependency.getId(), namespace);
    if (existingNode != null) {
      if (versionConstraint.isCompatible(
          existingNode.getAction().getExtension().getId().getVersion())) {
        ModifableExtensionPlanNode node =
            new ModifableExtensionPlanNode(extensionDependency, existingNode);
        addExtensionNode(node);
        parentBranch.add(node);

        return null;
      } else {
        if (existingNode.versionConstraint != null) {
          try {
            versionConstraint = versionConstraint.merge(existingNode.versionConstraint);
          } catch (IncompatibleVersionConstraintException e) {
            throw new InstallException(
                "Dependency ["
                    + extensionDependency
                    + "] is incompatible with current containt ["
                    + existingNode.versionConstraint
                    + "]",
                e);
          }
        } else {
          throw new InstallException(
              "Dependency ["
                  + extensionDependency
                  + "] incompatible with extension ["
                  + existingNode.getAction().getExtension()
                  + "]");
        }
      }
    }

    return versionConstraint;
  }
  /**
   * @param extensions the extensions containing the dependencies for which to merge the constraints
   * @param dependencyId the id of the dependency
   * @param previousMergedVersionContraint if not null it's merged with the provided extension
   *     dependencies version constraints
   * @return the merged version constraint
   * @throws IncompatibleVersionConstraintException the provided version constraint is compatible
   *     with the provided version constraint
   */
  private VersionConstraint mergeVersionConstraints(
      Collection<? extends Extension> extensions,
      String dependencyId,
      VersionConstraint previousMergedVersionContraint)
      throws IncompatibleVersionConstraintException {
    VersionConstraint mergedVersionContraint = previousMergedVersionContraint;

    if (extensions != null) {
      for (Extension extension : extensions) {
        ExtensionDependency dependency = getDependency(extension, dependencyId);

        if (dependency != null) {
          if (mergedVersionContraint == null) {
            mergedVersionContraint = dependency.getVersionConstraint();
          } else {
            mergedVersionContraint =
                mergedVersionContraint.merge(dependency.getVersionConstraint());
          }
        }
      }
    }

    return mergedVersionContraint;
  }