code: public static String pathElement(final int index,
                                     final String path) {
      final String[] paths = path.split("/");
  
      int idx = index;
  
      if ((paths[0] == null) || (paths[0].length() == 0)) {
        // skip empty first part - leading "/"
        idx++;
      }
  
      if (idx >= paths.length) {
        return null;
      }
  
      return paths[idx];
    }
docs: get the nth element from the path - first is 0.
  
  @param index of element we want
  @param path from which we extract the element
  @return element or null