private static boolean checkPattern(XPathExpression element) {
    if (element instanceof XPathBinaryExpression expression) {
      if (expression.getOperator() == XPathTokenTypes.UNION) {
        if (checkPattern(expression.getLOperand()) && checkPattern(expression.getROperand())) {
          return true;
        }
      }
    } else if (element instanceof XPathLocationPath) {
      return checkLocationPathPattern((XPathLocationPath)element);
    } else if (element instanceof XPathFunctionCall) {
      return checkIdKeyPattern(element);
    }
    return false;
  }
private static boolean checkPattern(XPathExpression element)