/**
   * Look for the specified policy element, using an XPath traversal of zone, template, and agent
   * nodes
   *
   * @param zoneId The zoneId to retrieve policy for
   * @param policySubPath The path of the policy to retrieve, such as "requestPolicy" or
   *     "eventPolicy/transmitPolicy"
   * @param objectName The object type to retrieve policy for
   * @return
   */
  private Element getPolicyElement(String zoneId, String policySubPath, String objectName) {
    if (fConfig != null) {
      JXPathContext xpathContext =
          JXPathContext.newContext(fConfig.getDocument().getDocumentElement());
      xpathContext.setLenient(true);

      // Look first, for policy located under the particular zone node
      Pointer currentPointer = xpathContext.getPointer("zone[@id='" + zoneId + "']");
      if (currentPointer != null && currentPointer.getNode() != null) {
        Element policyNode = findPolicy(xpathContext, currentPointer, policySubPath, objectName);
        if (policyNode != null) {
          return policyNode;
        }
        // No policy for this object found at the zone level, search for policy under the
        // template
        Element zoneNode = (Element) currentPointer.getNode();
        String templateId = zoneNode.getAttribute("template");
        if (templateId != null) {
          currentPointer = xpathContext.getPointer("template[@id='" + templateId + "']");
          policyNode = findPolicy(xpathContext, currentPointer, policySubPath, objectName);
          if (policyNode != null) {
            return policyNode;
          }
        }
      }

      // Finally, look at the root agent element
      currentPointer = xpathContext.getContextPointer();
      return findPolicy(xpathContext, currentPointer, policySubPath, objectName);
    }
    return null;
  }