Method replaceXpp3DOM.

@param parent
@param counter
@param parentDom
541598
@SuppressWarnings("unchecked")
   protected void replaceXpp3DOM(final Element parent, final Xpp3Dom parentDom, final Counter counter)
   {
      if (parentDom.getChildCount() > 0)
      {
         Xpp3Dom[] childs = parentDom.getChildren();
         Collection<Xpp3Dom> domChilds = new ArrayList<>();
         for (int i = 0; i < childs.length; i++)
         {
            domChilds.add(childs[i]);
         }

         ListIterator<Element> it = parent.getChildren().listIterator();
         while (it.hasNext())
         {
            Element elem = it.next();
            Iterator<Xpp3Dom> it2 = domChilds.iterator();
            Xpp3Dom corrDom = null;
            while (it2.hasNext())
            {
               Xpp3Dom dm = it2.next();
               if (dm.getName().equals(elem.getName()))
               {
                  corrDom = dm;
                  break;
               }
            }
            if (corrDom != null)
            {
               domChilds.remove(corrDom);
               replaceXpp3DOM(elem, corrDom, new Counter(counter.getDepth() + 1));
               counter.increaseCount();
            }
            else
            {
               it.remove();
            }
         }

         Iterator<Xpp3Dom> it2 = domChilds.iterator();
         while (it2.hasNext())
         {
            Xpp3Dom dm = it2.next();
            Element elem = factory.element(dm.getName(), parent.getNamespace());
            for (String attName : dm.getAttributeNames())
            {
               elem.setAttribute(attName, dm.getAttribute(attName));
            }
            insertAtPreferredLocation(parent, elem, counter);
            counter.increaseCount();
            replaceXpp3DOM(elem, dm, new Counter(counter.getDepth() + 1));
         }
      }
      else if (parentDom.getValue() != null)
      {
         parent.setText(parentDom.getValue());
      }
   }
1188248
public void replaceChild(int index, N newChild) {
    checkNotNull(newChild);
    tryRemoveFromOldParent(newChild);
    N oldChild = children.set(index, newChild);
    oldChild.setParent(null);
    newChild.setParent(master);
  }
1249742
protected void insertAtPreferredLocation(Element parent, Element child, Counter counter)
   {
      int contentIndex = 0;
      int elementCounter = 0;
      Iterator it = parent.getContent().iterator();
      Text lastText = null;
      int offset = 0;
      while (it.hasNext() && (elementCounter <= counter.getCurrentIndex()))
      {
         Object next = it.next();
         offset = offset + 1;
         if (next instanceof Element)
         {
            elementCounter = elementCounter + 1;
            contentIndex = contentIndex + offset;
            offset = 0;
         }
         if ((next instanceof Text) && it.hasNext())
         {
            lastText = (Text) next;
         }
      }
      if ((lastText != null) && (lastText.getTextTrim().length() == 0))
      {
         lastText = (Text) lastText.clone();
      }
      else
      {
         StringBuilder starter = new StringBuilder(lineSeparator);
         for (int i = 0; i < counter.getDepth(); i++)
         {
            starter.append("  "); // TODO make settable?
         }
         lastText = factory.text(starter.toString());
      }
      if (parent.getContentSize() == 0)
      {
         Text finalText = (Text) lastText.clone();
         finalText.setText(finalText.getText().substring(0, finalText.getText().length() - "  ".length()));
         parent.addContent(contentIndex, finalText);
      }
      parent.addContent(contentIndex, child);
      parent.addContent(contentIndex, lastText);
   }
647748
def add_to(self, parent, additions):
        ""
        for x in additions:
            if x not in parent:
                parent.append(x)
                self.changed()
711137
protected void updateReporting(Reporting value, String xmlTag, Counter counter, Element element)
   {
      boolean shouldExist = value != null;
      Element root = updateElement(counter, element, xmlTag, shouldExist);
      if (shouldExist)
      {
         Counter innerCount = new Counter(counter.getDepth() + 1);
         findAndReplaceSimpleElement(innerCount, root, "excludeDefaults",
                  (value.isExcludeDefaults() == false) ? null : String.valueOf(value.isExcludeDefaults()), "false");
         findAndReplaceSimpleElement(innerCount, root, "outputDirectory", value.getOutputDirectory(), null);
         iterateReportPlugin(innerCount, root, value.getPlugins(), "plugins", "plugin");
      }
   }
48734
public static ParenthesizedExpression parenthesizeAndReplace(Expression expression) {
    ParenthesizedExpression newExpr = new ParenthesizedExpression();
    expression.replaceWith(newExpr);
    newExpr.setExpression(expression);
    return newExpr;
  }
496048
protected void mergeParent(CmsADEConfigDataInternal parent) {

        List<CmsResourceTypeConfig> parentTypes = null;
        if (parent != null) {
            parentTypes = parent.m_ownResourceTypes;
        } else {
            parentTypes = Collections.emptyList();
        }

        List<CmsPropertyConfig> parentProperties = null;
        if (parent != null) {
            parentProperties = parent.m_ownPropertyConfigurations;
        } else {
            parentProperties = Collections.emptyList();
        }

        List<CmsModelPageConfig> parentModelPages = null;
        if (parent != null) {
            parentModelPages = parent.m_ownModelPageConfig;
        } else {
            parentModelPages = Collections.emptyList();
        }

        List<CmsFunctionReference> parentFunctionRefs = null;
        if (parent != null) {
            parentFunctionRefs = parent.m_functionReferences;
        } else {
            parentFunctionRefs = Collections.emptyList();
        }

        m_ownResourceTypes = CmsADEConfigData.combineConfigurationElements(parentTypes, m_ownResourceTypes, false);
        m_ownPropertyConfigurations = CmsADEConfigData.combineConfigurationElements(
            parentProperties,
            m_ownPropertyConfigurations,
            false);
        m_ownModelPageConfig = CmsADEConfigData.combineConfigurationElements(
            parentModelPages,
            m_ownModelPageConfig,
            false);
        m_functionReferences = CmsADEConfigData.combineConfigurationElements(
            parentFunctionRefs,
            m_functionReferences,
            false);
        if ((parent != null) && (m_ownDynamicFunctions == null)) {
            m_dynamicFunctions = parent.m_dynamicFunctions;
        } else {
            m_dynamicFunctions = m_ownDynamicFunctions;
        }
    }
121516
function replace(node, parent, scope, remaps) {
  var remap = remaps[node.name];
  if (!remap) return;

  var ownBinding = scope.getBindingIdentifier(node.name);
  if (ownBinding === remap.binding) {
    node.name = remap.uid;
  } else {
    // scope already has it's own binding that doesn't
    // match the one we have a stored replacement for
    if (this) this.skip();
  }
}
52497
private static Node replaceReturnWithBreak(Node current, Node parent,
      String resultName, String labelName) {

    if (current.isFunction()
        || current.isExprResult()) {
      // Don't recurse into functions definitions, and expressions can't
      // contain RETURN nodes.
      return current;
    }

    if (current.isReturn()) {
      checkState(NodeUtil.isStatementBlock(parent));

      Node resultNode = getReplacementReturnStatement(current, resultName);
      Node breakNode = IR.breakNode(IR.labelName(labelName));

      // Replace the node in parent, and reset current to the first new child.
      breakNode.useSourceInfoIfMissingFromForTree(current);
      parent.replaceChild(current, breakNode);
      if (resultNode != null) {
        resultNode.useSourceInfoIfMissingFromForTree(current);
        parent.addChildBefore(resultNode, breakNode);
      }
      current = breakNode;
    } else {
      for (Node c = current.getFirstChild(); c != null; c = c.getNext()) {
        // c may be replaced.
        c = replaceReturnWithBreak(c, current, resultName, labelName);
      }
    }

    return current;
  }
535187
protected void updateBuildBase(BuildBase value, String xmlTag, Counter counter, Element element)
   {
      boolean shouldExist = value != null;
      Element root = updateElement(counter, element, xmlTag, shouldExist);
      if (shouldExist)
      {
         Counter innerCount = new Counter(counter.getDepth() + 1);
         findAndReplaceSimpleElement(innerCount, root, "defaultGoal", value.getDefaultGoal(), null);
         iterateResource(innerCount, root, value.getResources(), "resources", "resource");
         iterateResource(innerCount, root, value.getTestResources(), "testResources", "testResource");
         findAndReplaceSimpleElement(innerCount, root, "directory", value.getDirectory(), null);
         findAndReplaceSimpleElement(innerCount, root, "finalName", value.getFinalName(), null);
         findAndReplaceSimpleLists(innerCount, root, value.getFilters(), "filters", "filter");
         updatePluginManagement(value.getPluginManagement(), "pluginManagement", innerCount, root);
         iteratePlugin(innerCount, root, value.getPlugins(), "plugins", "plugin");
      }
   }
384245
function(parent, count)
	{
		count = count || 1;
		var br = null;
		
		for (var i = 0; i < count; i++)
		{
			if (parent != null)
			{
				br = parent.ownerDocument.createElement('br');
				parent.appendChild(br);
			}
		}
		
		return br;
	}
1310707
function overrideTags (parent, child, telegraf) {
  const childCopy = {};
  const toAppend = [];
  formatTags(child, telegraf).forEach(tag => {
    const idx = typeof tag === 'string' ? tag.indexOf(':') : -1;
    if (idx < 1) { // Not found or first character
      toAppend.push(tag);
    } else {
      childCopy[tag.substring(0, idx)] = tag.substring(idx + 1);
    }
  });
  const result = parent.map(tag => {
    const idx = typeof tag === 'string' ? tag.indexOf(':') : -1;
    if (idx < 1) { // Not found or first character
      return tag;
    }
    const key = tag.substring(0, idx);
    if (childCopy.hasOwnProperty(key)) {
      const value = childCopy[key];
      delete childCopy[key];
      return `${key}:${value}`;
    }
    return tag;
  });
  Object.keys(childCopy).forEach(key => {
    result.push(`${key}:${childCopy[key]}`);
  });
  return result.concat(toAppend);
}
557338
private void updateCurrentFunction(AbstractFunctionExpression parentExpr) {
        GroovyExpression expr = parentExpr.getCaller();
        if (expr instanceof AbstractFunctionExpression) {
            AbstractFunctionExpression exprAsFunction = (AbstractFunctionExpression) expr;
            GroovyExpression exprCaller = exprAsFunction.getCaller();
            parentExpr.setCaller(exprCaller);
            updateCurrentFunctionDefintion(exprAsFunction);
        }
    }
91388
protected void updateRepositoryPolicy(RepositoryPolicy value, String xmlTag, Counter counter, Element element)
   {
      boolean shouldExist = value != null;
      Element root = updateElement(counter, element, xmlTag, shouldExist);
      if (shouldExist)
      {
         Counter innerCount = new Counter(counter.getDepth() + 1);
         findAndReplaceSimpleElement(innerCount, root, "enabled",
                  (value.isEnabled() == true) ? null : String.valueOf(value.isEnabled()), "true");
         findAndReplaceSimpleElement(innerCount, root, "updatePolicy", value.getUpdatePolicy(), null);
         findAndReplaceSimpleElement(innerCount, root, "checksumPolicy", value.getChecksumPolicy(), null);
      }
   }
856397
protected void updatePatternSet(PatternSet value, String xmlTag, Counter counter, Element element)
   {
      boolean shouldExist = value != null;
      Element root = updateElement(counter, element, xmlTag, shouldExist);
      if (shouldExist)
      {
         Counter innerCount = new Counter(counter.getDepth() + 1);
         findAndReplaceSimpleLists(innerCount, root, value.getIncludes(), "includes", "include");
         findAndReplaceSimpleLists(innerCount, root, value.getExcludes(), "excludes", "exclude");
      }
   }
250448
void appendMixinsTo( String[] parentSelector, CssFormatter formatter ) {
        for( Formattable prop : properties ) {
            switch( prop.getType()) {
                case MIXIN:
                    ((Mixin)prop).appendSubRules( parentSelector, formatter );
                    break;
                case CSS_AT_RULE:
                case COMMENT:
                    prop.appendTo( formatter );
                    break;
            }
        }
    }
1344461
protected void updateExclusion(Exclusion value, String xmlTag, Counter counter, Element element)
   {
      Element root = element;
      Counter innerCount = new Counter(counter.getDepth() + 1);
      findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null);
      findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null);
   }