String makeUnique(String uniquePath, XmlElement what) {
      final XmlFile file = (XmlFile)what.getContainingFile();
      assert file != null;
      try {
        final XPath xPath = xpathSupport.createXPath(file, uniquePath, Namespace.fromMap(usedPrefixes));
        final Object o = xPath.evaluate(file.getDocument());
        if (o instanceof List list) {
          //noinspection RawUseOfParameterizedType
          if (list.size() > 1) {
            if (what instanceof XmlTag tag) {
              final XmlAttribute[] attributes = tag.getAttributes();
              for (XmlAttribute attribute : attributes) {
                final String name = attribute.getName();
                final XmlAttributeDescriptor descriptor = attribute.getDescriptor();
                final String value = attribute.getValue();
                if (value != null
                    && ((descriptor != null && descriptor.hasIdType())
                        || name.equalsIgnoreCase("id")
                        || name.equalsIgnoreCase("name"))
                    && isUniqueAttrValueAmongSiblings(tag, name, value)) {
                  return uniquePath + "[@" + name + "='" + attribute.getValue() + "']";
                }
              }
            }

            int i = 1;
            for (Object o1 : list) {
              if (o1 == what) {
                return uniquePath + "[" + i + "]";
              }
              else {
                i++;
              }
            }
            assert false : "Expression " + uniquePath + " didn't find input element " + what;
          }
        }
        else {
          assert false : "Unknown return value: " + o;
        }
      }
      catch (JaxenException e) {
        Logger.getInstance("XPathExpressionGenerator").error(e);
      }
      return uniquePath;
    }
String makeUnique(String uniquePath, XmlElement what)