code: public static Object selectObject(Node node, String xpathQuery) {
          Object result = node.selectObject(xpathQuery);
          if (result != null && result instanceof Collection && ((Collection) result).isEmpty()) {
              return null;
          } else {
              return result;
          }
      }
docs: Executes an XPath query to retrieve an object. Normally, if the XPath result doesn't have a result, an
  empty collection is returned. This object checks that case and returns null accordingly.