code: public static String createXpathElementCheck(String path, int index) {
  
          if (path.charAt(path.length() - 1) == ']') {
              // path is already in the form "title[1]"
              // ignore provided index and return the path "as is"
              return path;
          }
  
          // append index in square brackets
          return createXpathElement(path, index);
      }
docs: Ensures that a provided simplified Xpath has the format <code>title[1]</code>.<p>
  
  This method is used if it's uncertain if some path does have
  a square bracket already appended or not.<p>
  
  Note: If the name already has the format <code>title[1]</code>, then provided index parameter
  is ignored.<p>
  
  @param path the path to get the simplified Xpath for
  @param index the index to append (if required)
  
  @return the simplified Xpath for the given name