// reconcileChildren reconciles children of the current HTML against a previous
// render's DOM nodes.
487599
func (h *HTML) reconcileChildren(prev *HTML) (pendingMounts []Mounter) {
	hasKeyedChildren := len(h.keyedChildren) > 0
	prevHadKeyedChildren := len(prev.keyedChildren) > 0
	for i, nextChild := range h.children {
		// Determine concrete type if necessary.
		switch v := nextChild.(type) {
		case *HTML:
			// If the type of the child is *HTML, but its value is nil, replace
			// the child with a concrete nil, to ensure consistent render
			// handling.
			if v == nil {
				nextChild = nil
				h.children[i] = nextChild
			}
		case List:
			// Replace List with keyedList, which can handle nested keys and
			// children.
			nextChild = KeyedList{html: &HTML{children: v}}
			h.children[i] = nextChild
		}

		// Ensure children implement the keyer interface consistently, and
		// populate the keyedChildren map now.
		//
		// TODO(pdf): Add tests for node equality, keyed children
		var (
			new     = h.node != prev.node
			nextKey interface{}
		)
		keyer, isKeyer := nextChild.(Keyer)
		if hasKeyedChildren && !isKeyer {
			panic("vecty: all siblings must have keys when using keyed elements")
		}
		if isKeyer {
			nextKey = keyer.Key()
			if hasKeyedChildren && nextKey == nil {
				panic("vecty: all siblings must have keys when using keyed elements")
			}
			if nextKey != nil {
				if h.keyedChildren == nil {
					h.keyedChildren = make(map[interface{}]ComponentOrHTML)
				}
				if _, exists := h.keyedChildren[nextKey]; exists {
					panic("vecty: duplicate sibling key")
				}
				// Store the keyed child.
				h.keyedChildren[nextKey] = nextChild
				hasKeyedChildren = true
			}
		}

		// If this is a new element (changed type, or did not exist previously),
		// simply add the element directly. The existence of keyed children
		// can not be determined by children index, so skip if keyed.
		if (i >= len(prev.children) && !hasKeyedChildren) || new {
			if nextChildList, ok := nextChild.(KeyedList); ok {
				pendingMounts = append(pendingMounts, nextChildList.reconcile(h, nil)...)
				continue
			}
			nextChildRender, skip, mounters := render(nextChild, nil)
			if skip || nextChildRender == nil {
				continue
			}
			pendingMounts = append(pendingMounts, mounters...)
			if m, ok := nextChild.(Mounter); ok {
				pendingMounts = append(pendingMounts, m)
			}
			h.lastRenderedChild = nextChildRender

			// Note: we must insertBefore not appendChild because if we're
			// rendering inside a list with unkeyed children, we will have an
			// insertion node here.
			h.insertBefore(h.insertBeforeNode, nextChildRender)
			continue
		}

		var prevChild ComponentOrHTML
		if len(prev.children) > i {
			prevChild = prev.children[i]
		}
		// Find previous keyed sibling if exists, and mutate from there.
		if hasKeyedChildren {
			if prevKeyedChild, ok := prev.keyedChildren[nextKey]; ok {
				prevChild = prevKeyedChild
			} else {
				prevChild = nil
			}
		}

		var prevChildRender *HTML
		// If the previous child was not a list, extract the previous child
		// render.
		if _, isList := prevChild.(KeyedList); !isList {
			prevChildRender = extractHTML(prevChild)
		}

		// If the previous child render was nil try to find the next DOM node
		// in the previous render so that we can insert this child at the
		// correct location.
		if prevChildRender == nil && h.insertBeforeNode == nil {
			// If we have not rendered any children yet, take the insert
			// position from the first child, if any, otherwise use the
			// next sibling from the last rendered child.
			if h.lastRenderedChild == nil {
				h.insertBeforeNode = h.firstChild()
			} else {
				h.insertBeforeNode = h.lastRenderedChild.nextSibling()
			}
		}
		// If our insertion node is the current previous child, advance to the
		// next sibling.
		if prevChildRender != nil && prevChildRender.node == h.insertBeforeNode {
			h.insertBeforeNode = h.insertBeforeNode.Get("nextSibling")
		}

		// If the next child is a list, reconcile its elements in-place, and
		// we're done.
		if nextChildList, ok := nextChild.(KeyedList); ok {
			pendingMounts = append(pendingMounts, nextChildList.reconcile(h, prevChild)...)
			continue
		}

		// If the previous child was a list, remove the list elements from the
		// previous render, since we no longer have a list.
		if prevChildList, ok := prevChild.(KeyedList); ok {
			prevChildList.remove(h)
			prevChild = nil
		}

		// If we're keyed, find the next DOM node from the previous render to
		// insert before, for reordering.
		var (
			insertBeforeKeyedNode jsObject
			stableKey             bool
		)
		if hasKeyedChildren {
			insertBeforeKeyedNode = h.lastRenderedChild.nextSibling()
			// If the next node is our old node, mark key as stable, to avoid
			// unnecessary insertion.
			if prevChildRender != nil && prevChildRender.node == insertBeforeKeyedNode {
				stableKey = true
				insertBeforeKeyedNode = nil
			}
		}

		// Determine the next child render.
		nextChildRender, skip, mounters := render(nextChild, prevChild)
		if nextChildRender != nil && prevChildRender != nil && nextChildRender == prevChildRender {
			panic("vecty: next child render must not equal previous child render (did the child Render illegally return a stored render variable?)")
		}

		// Store the last rendered child to determine insertion target for
		// subsequent children.
		if nextChildRender != nil {
			h.lastRenderedChild = nextChildRender
		}

		// If the previous and next child are components of the same type, then
		// keep prevChildComponent as our child so that the next time we are
		// here prevChild will be the same pointer. We do this because
		// prevChildComponent is the persistent component instance.
		if prevChildComponent, ok := prevChild.(Component); ok {
			if nextChildComponent, ok := nextChild.(Component); ok && sameType(prevChildComponent, nextChildComponent) {
				h.children[i] = prevChild
				nextChild = prevChild
				if hasKeyedChildren {
					h.keyedChildren[nextKey] = prevChild
				}
			}
		}
		if skip {
			continue
		}
		pendingMounts = append(pendingMounts, mounters...)

		// Perform the final reconciliation action for nextChildRender and
		// prevChildRender. Replace, remove, insert or append the DOM nodes.
		switch {
		case nextChildRender == nil && prevChildRender == nil:
			continue // nothing to do.
		case nextChildRender != nil && prevChildRender != nil:
			if m := mountUnmount(nextChild, prevChild); m != nil {
				pendingMounts = append(pendingMounts, m)
			}

			if hasKeyedChildren && (prevChildRender != nil && prevChildRender.node == nextChildRender.node) {
				// We are re-using the name node. Remove the children from
				// keyedChildren so that we don't remove it when we remove dangling
				// children below.
				delete(prev.keyedChildren, nextKey)
			}

			// If we do not have keyed siblings, or the key is stable, replace
			// the previous node (may be NOOP for equivalent nodes).
			if !hasKeyedChildren || stableKey {
				replaceNode(nextChildRender.node, prevChildRender.node)
				continue
			}
			// Moving keyed children need to be inserted (which moves existing
			// nodes), rather than replacing the previous child at this
			// position.
			if insertBeforeKeyedNode != nil {
				// Insert before the next sibling, if we have one.
				h.insertBefore(insertBeforeKeyedNode, nextChildRender)
				continue
			}
			h.insertBefore(h.insertBeforeNode, nextChildRender)
		case nextChildRender == nil && prevChildRender != nil:
			h.removeChild(prevChildRender)
		case nextChildRender != nil && prevChildRender == nil:
			if m, ok := nextChild.(Mounter); ok {
				pendingMounts = append(pendingMounts, m)
			}
			if insertBeforeKeyedNode != nil {
				// Insert before the next keyed sibling, if we have one.
				h.insertBefore(insertBeforeKeyedNode, nextChildRender)
				continue
			}
			h.insertBefore(h.insertBeforeNode, nextChildRender)
		default:
			panic("vecty: internal error (unexpected switch state)")
		}
	}

	// If dealing with keyed siblings, remove all prev.keyedChildren which are
	// leftovers / ones we did not find a match for above.
	if prevHadKeyedChildren && hasKeyedChildren {
		// Convert prev.keyedChildren map to slice, and invoke removeChildren.
		prevChildren := make([]ComponentOrHTML, len(prev.keyedChildren))
		i := 0
		for _, c := range prev.keyedChildren {
			prevChildren[i] = c
			i++
		}
		h.removeChildren(prevChildren)
		return pendingMounts
	}

	if len(prev.children) > len(h.children) {
		// Remove every previous child that h.children does not have in common.
		h.removeChildren(prev.children[len(h.children):])
	}
	return pendingMounts
}
559999
func (cmd *Command) ListChildren() []string {
	if cmd.nochild() {
		return []string{}
	}

	ret := make([]string, 0, len(cmd.children))
	for _, child := range cmd.children {
		ret = append(ret, child.Name)
	}
	return ret
}
1332747
func (n *regexNode) removeChildren(startIndex, endIndex int) {
	n.children = append(n.children[:startIndex], n.children[endIndex:]...)
}
108468
func (c *ClassList) Reconcile(m *ClassList) bool {
	var added bool
	maxlen := len(c.list)
	for ind, val := range m.list {
		if ind >= maxlen {
			added = true
			c.list = append(c.list, val)
			continue
		}

		if c.list[ind] == val {
			continue
		}

		added = true
		c.list[ind] = val
	}

	return added
}
328841
func (r *Reconciler) reconcile() error {
	missingPvtDataTracker, err := r.GetMissingPvtDataTracker()
	if err != nil {
		logger.Error("reconciliation error when trying to get missingPvtDataTracker:", err)
		return err
	}
	if missingPvtDataTracker == nil {
		logger.Error("got nil as MissingPvtDataTracker, exiting...")
		return errors.New("got nil as MissingPvtDataTracker, exiting...")
	}
	totalReconciled, minBlock, maxBlock := 0, uint64(math.MaxUint64), uint64(0)

	defer r.reportReconciliationDuration(time.Now())

	for {
		missingPvtDataInfo, err := missingPvtDataTracker.GetMissingPvtDataInfoForMostRecentBlocks(r.config.BatchSize)
		if err != nil {
			logger.Error("reconciliation error when trying to get missing pvt data info recent blocks:", err)
			return err
		}
		// if missingPvtDataInfo is nil, len will return 0
		if len(missingPvtDataInfo) == 0 {
			if totalReconciled > 0 {
				logger.Infof("Reconciliation cycle finished successfully. reconciled %d private data keys from blocks range [%d - %d]", totalReconciled, minBlock, maxBlock)
			} else {
				logger.Debug("Reconciliation cycle finished successfully. no items to reconcile")
			}
			return nil
		}

		logger.Debug("got from ledger", len(missingPvtDataInfo), "blocks with missing private data, trying to reconcile...")

		dig2collectionCfg, minB, maxB := r.getDig2CollectionConfig(missingPvtDataInfo)
		fetchedData, err := r.FetchReconciledItems(dig2collectionCfg)
		if err != nil {
			logger.Error("reconciliation error when trying to fetch missing items from different peers:", err)
			return err
		}
		if len(fetchedData.AvailableElements) == 0 {
			logger.Warning("missing private data is not available on other peers")
			return nil
		}

		pvtDataToCommit := r.preparePvtDataToCommit(fetchedData.AvailableElements)
		// commit missing private data that was reconciled and log mismatched
		pvtdataHashMismatch, err := r.CommitPvtDataOfOldBlocks(pvtDataToCommit)
		if err != nil {
			return errors.Wrap(err, "failed to commit private data")
		}
		r.logMismatched(pvtdataHashMismatch)
		if minB < minBlock {
			minBlock = minB
		}
		if maxB > maxBlock {
			maxBlock = maxB
		}
		totalReconciled += len(fetchedData.AvailableElements)
	}
}
1195748
func (n *node) childrenEqual(other *node) bool {
	if len(n.children) != len(other.children) {
		return false
	}
	for keyPart, child := range n.children {
		otherChild, ok := other.children[keyPart]
		if !ok || !child.equal(otherChild) {
			return false
		}
	}
	return true
}
883411
func DeleteChildren(conn ZookeeperConnection, path string, deleteSelf bool) error {
	if err := ValidatePath(path); err != nil {
		return err
	}

	if children, _, err := conn.Children(path); err != nil {
		return err
	} else {
		for _, child := range children {
			if err := DeleteChildren(conn, JoinPath(path, child), true); err != nil {
				return err
			}
		}
	}

	if deleteSelf {
		if err := conn.Delete(path, -1); err != nil {
			switch err {
			case zk.ErrNotEmpty:
				return DeleteChildren(conn, path, true)
			case zk.ErrNoNode:
				return nil
			default:
				return err
			}
		}
	}

	return nil
}
867040
func (n *cachedNode) childs() []common.Hash {
	children := make([]common.Hash, 0, 16)
	for child := range n.children {
		children = append(children, child)
	}
	if _, ok := n.node.(rawNode); !ok {
		gatherChildren(n.node, &children)
	}
	return children
}
64784
func (i *ImageService) Children(id image.ID) []image.ID {
	return i.imageStore.Children(id)
}
526284
func (s *ListChildrenOutput) SetChildren(v []*Child) *ListChildrenOutput {
	s.Children = v
	return s
}
967351
func (s *Selection) ChildrenMatcher(m Matcher) *Selection {
	return filterAndPush(s, getChildrenNodes(s.Nodes, siblingAll), m)
}
368325
func (t *Tab) invalidateChildren(node *gcdapi.DOMNode) {
	// invalidate & remove ContentDocument node and children
	if node.ContentDocument != nil {
		ele, ok := t.getElement(node.ContentDocument.NodeId)
		if ok {
			t.invalidateRemove(ele)
			t.invalidateChildren(node.ContentDocument)
		}
	}

	if node.Children == nil {
		return
	}

	// invalidate node.Children
	for _, child := range node.Children {
		ele, ok := t.getElement(child.NodeId)
		if !ok {
			continue
		}
		t.invalidateRemove(ele)
		// recurse and remove children of this node
		t.invalidateChildren(ele.node)
	}
}
956138
func (a *Attribute) Reconcile(m *Attribute) bool {
	if strings.TrimSpace(a.Name) == strings.TrimSpace(m.Name) {
		a.Value = m.Value
		return true
	}
	return false
}
920329
func (dd *DirData) GetChildren(ctx context.Context) (
	children map[string]EntryInfo, err error) {
	topBlock, err := dd.GetTopBlock(ctx, BlockRead)
	if err != nil {
		return nil, err
	}

	_, blocks, _, err := dd.tree.getBlocksForOffsetRange(
		ctx, dd.rootBlockPointer(), topBlock, topBlock.FirstOffset(), nil,
		false, true)
	if err != nil {
		return nil, err
	}

	numEntries := 0
	for _, b := range blocks {
		numEntries += len(b.(*DirBlock).Children)
	}
	children = make(map[string]EntryInfo, numEntries)
	for _, b := range blocks {
		for k, de := range b.(*DirBlock).Children {
			if hiddenEntries[k] {
				continue
			}
			children[k] = de.EntryInfo
		}
	}
	return children, nil
}
30814
func (r Root) Children() []Root {
	child := r.Pointer.FirstChild
	var children []Root
	for child != nil {
		children = append(children, Root{child, child.Data, nil})
		child = child.NextSibling
	}
	return children
}
701570
func (b *Builder) SetHasChildren() {
	if len(b.tagStack) <= 0 {
		panic("NoChildren with no open tags")
	}
	b.tagStack[len(b.tagStack)-1].children = true
}
278689
func (entity *AEBackupInformation) FetchChildren(c context.Context) error {
	g := goon.FromContext(c)

	// AEBackupInformationKindFilesList の処理
	{
		var backupInfoKindFilesList []*AEBackupInformationKindFiles
		qb := newAEBackupInformationKindFilesQueryBuilder().Ancestor(g.Key(entity))
		_, err := g.GetAll(qb.Query(), &backupInfoKindFilesList)
		if err != nil {
			log.Infof(c, "on AEBackupInformationKindFiles#GetAll: %s", err.Error())
			return err
		}
		for _, backupInfoKindFiles := range backupInfoKindFilesList {
			err := backupInfoKindFiles.FetchChildren(c)
			if err != nil {
				log.Infof(c, "on AEBackupInformationKindFiles#FetchChildren: %s", err.Error())
				return err
			}
		}
		entity.AEBackupInformationKindFilesList = backupInfoKindFilesList
	}

	return nil
}