/**
   * Find the current dasextension::query::sites element or create a new one in the proper place in
   * the given dasextension element.
   *
   * @param dasExt - mandatory - must be a valid dasextension Element
   * @return
   */
  public ExtensibleElement getSites(ExtensibleElement dasExt) {

    // get reference to the dasextension::query element in feed
    ExtensibleElement query = this.getQuery(dasExt);

    // get reference to the dasextension::query::sites element in feed
    QName sitesQname = new QName(this.dasextensionNamespace, "sites");
    ExtensibleElement sites = query.getExtension(sitesQname);
    if (NullChecker.isEmpty(sites)) {
      ExtensibleElement queryFirstChild = query.getFirstChild();
      if (NullChecker.isEmpty(queryFirstChild)) {
        // no children in query, so merely add sites element
        sites = query.addExtension(sitesQname);
      } else {
        QName fCQname = queryFirstChild.getQName();
        if ("parameters".equals(fCQname.getLocalPart())) {
          ExtensibleElement querySecondChild = query.getNextSibling();
          if (NullChecker.isEmpty(querySecondChild)) {
            // no second child in query, so add sites after parameters
            sites = query.addExtension(sitesQname);
          } else {
            // add sites after parameters, and before the second child
            QName sCQname = querySecondChild.getQName();
            sites = query.addExtension(sitesQname, sCQname);
          }
        } else {
          // another element besides parameters is first child,
          //  so add sites before this
          sites = dasExt.addExtension(sitesQname, fCQname);
        }
      }
    }
    return sites;
  }
  /**
   * Find the current dasextension::query element or create a new one in the proper place in the
   * given dasextension element.
   *
   * @param dasExt - mandatory - must be a valid dasextension Element
   * @return
   */
  private ExtensibleElement getQuery(ExtensibleElement dasExt) {

    QName queryQname = new QName(this.dasextensionNamespace, "query");
    // attempt to get query element
    ExtensibleElement query = dasExt.getExtension(queryQname);
    if (NullChecker.isEmpty(query)) {
      // there is no query element, so create one in the proper place
      ExtensibleElement firstChild = dasExt.getFirstChild();
      if (NullChecker.isEmpty(firstChild)) {
        // no children, so merely add query
        query = dasExt.addExtension(queryQname);
      } else {
        QName fCQname = firstChild.getQName();
        if ("path".equals(fCQname.getLocalPart())) {
          // path is the firstChild, so get the second child
          ExtensibleElement secondChild = firstChild.getNextSibling();
          if (NullChecker.isEmpty(secondChild)) {
            // no second child, so add query after path
            query = dasExt.addExtension(queryQname);
          } else {
            QName sCQname = secondChild.getQName();
            // have a second child, so add query after
            // path element and before second child
            query = dasExt.addExtension(queryQname, sCQname);
          }
        } else {
          // add query before the first child element
          query = dasExt.addExtension(queryQname, fCQname);
        }
      }
    }
    return query;
  }