code: private String getContentItemForXPath(Map<String, String> contentItems, String xpath) {
  
          if (contentItems.get(xpath) != null) { // content item found for XPath
              return contentItems.get(xpath);
          } else { // try a multiple value mapping and ensure that the values are in correct order.
              SortedMap<List<Integer>, String> valueMap = new TreeMap<>(new Comparator<List<Integer>>() {
  
                  // expects lists of the same length that contain only non-null values. This is given for the use case.
                  @SuppressWarnings("boxing")
                  public int compare(List<Integer> l1, List<Integer> l2) {
  
                      for (int i = 0; i < l1.size(); i++) {
                          int numCompare = Integer.compare(l1.get(i), l2.get(i));
                          if (0 != numCompare) {
                              return numCompare;
                          }
                      }
                      return 0;
                  }
              });
              for (Map.Entry<String, String> entry : contentItems.entrySet()) {
                  if (CmsXmlUtils.removeXpath(entry.getKey()).equals(xpath)) { // the removed path refers an item
  
                      String[] xPathParts = entry.getKey().split("/");
                      List<Integer> indexes = new ArrayList<>(xPathParts.length);
                      for (String xPathPart : Arrays.asList(xPathParts)) {
                          if (!xPathPart.isEmpty()) {
                              indexes.add(Integer.valueOf(CmsXmlUtils.getXpathIndexInt(xPathPart)));
                          }
                      }
                      valueMap.put(indexes, entry.getValue());
                  }
              }
              StringBuffer result = new StringBuffer();
              for (String value : valueMap.values()) {
                  result.append(value);
                  result.append("\n");
              }
              return result.length() > 1 ? result.toString().substring(0, result.length() - 1) : null;
          }
      }
docs: Returns a "\n" separated String of values for the given XPath if according content items can be found.<p>
  
  @param contentItems the content items to get the value from
  @param xpath the short XPath parameter to get the value for
  
  @return a "\n" separated String of element values found in the content items for the given XPath