/**
  * @param parent the parent node
  * @param child the child node
  * @return the position of the child node within the array of children or -1 if there is no parent
  *     child relationship
  */
 public static int indexOf(Node parent, Node child) {
   for (int i = 0; i < parent.getChildCount(); i++) {
     if (child.equals(parent.getChild(i))) {
       return i;
     }
   }
   return -1;
 }
 private void moveTosCopyRight() {
   // move the ToS and copyright to the top
   // create a div group in the graphics context
   if (tosGroup == null) {
     String graphicsId = map.getVectorContext().getId();
     Element graphics = DOM.getElementById(graphicsId);
     tosGroup = DOM.createDiv();
     tosGroup.setId(map.getID() + "-googleAddon");
     tosGroup.getStyle().setBottom(VERTICAL_MARGIN, Unit.PX);
     graphics.appendChild(tosGroup);
     UIObject.setVisible(tosGroup, visible);
   }
   String mapsId = map.getRasterContext().getId(this);
   Element gmap = DOM.getElementById(mapsId);
   if (gmap.getChildCount() > 0) {
     Node baseMap = gmap.getChild(0);
     if (baseMap.getChildCount() > 2) {
       Node copyright = baseMap.getChild(1);
       Node tos = baseMap.getChild(2);
       tosGroup.appendChild(copyright);
       tosGroup.appendChild(tos);
     }
   }
 }
  /**
   * Recursively walks the tree depth first and creates a list of affected nodes.
   *
   * @param curNode the (relative) root node to start with
   */
  private void walk(Node curNode) {

    // check if we're still within the affected subtree
    // and the current node has any taggable content
    if (!this.outOfAffectedSubtree
        && ((curNode.getNodeValue() == null) || !curNode.getNodeValue().trim().isEmpty())) {

      // all text nodes gets added, in case we get into the affected subtree with this
      // node or one of its children
      if (curNode.getNodeType() == Node.TEXT_NODE) {
        affectedNodes.push(curNode);
      }

      // we check for children and go down the subtrees
      if (curNode.hasChildNodes()) {
        for (int i = 0; i < curNode.getChildCount(); i++) {
          walk(curNode.getChild(i));
        }
      }
      // if we reach the outer left node
      // we're in the affacted subtree -> all parent nodes can stay on the stack
      else if (curNode.equals(outerLeftNode)) {
        this.inAffectedSubtree = true;
      }
      // if we reach the outer right node
      // we reject all the rest of the upcoming nodes
      else if (curNode.equals(outerRightNode)) {
        this.outOfAffectedSubtree = true;
      }
      // if the current node is a text node it has already been pushed onto the stack
      // and if we're not within the affected subtree, we're removing the current node from the
      // stack
      // (not being in the affected subtree means neither the current node nor one of its
      //  children is the outer left node)
      if (!inAffectedSubtree && (curNode.getNodeType() == Node.TEXT_NODE)) {
        affectedNodes.pop();
      }
    }
  }