code: public boolean matches(String xpath, boolean includeParent) {
          if (xpath == null || xpath.equals("")) {
              throw new IllegalArgumentException("xpath cannot be null or empty");
          }
  
          // make sure xpath doesn't end with an /
          if (xpath.endsWith("/")) {
              throw new IllegalArgumentException("Should not end with /");
          }
  
          // the xpath might be a parent path
          if (includeParent && normalizedXPath.startsWith(xpath+"/")) {
              return true;
          }
  
          // otherwise, either this is an exact match or a child of a previous match
          if (xpath.startsWith(normalizedXPath)) {
              // if lengths are equal, then its a perfect match
              if (xpath.length() == normalizedXPath.length()) {
                  return true;
              } else if (includeChildren) {
                  return true;
              } else {
                  return false;
              }
          }
          return false;
      }
docs: Does the path match?  If includeParent is true, then a parent match
  is included.  For example, an XPath of "/nodeA/nodeB" will include a match
  for "/nodeA" if includeParent is true.  Otherwise, "/nodeA" will return
  false.
  
  @param xpath A path such as "/nodeA/nodeB"
  @return True if the xpath matches, false otherwise.