formats the ac tree - entity with child elements
347099
def __get_ac_tree(self, ac: model.AssetClass, with_stocks: bool):
        
        output = []
        output.append(self.__get_ac_row(ac))

        for child in ac.classes:
            output += self.__get_ac_tree(child, with_stocks)

        if with_stocks:
            for stock in ac.stocks:
                row = None
                if isinstance(stock, Stock):
                    row = self.__get_stock_row(stock, ac.depth + 1)
                elif isinstance(stock, CashBalance):
                    row = self.__get_cash_row(stock, ac.depth + 1)
                output.append(row)

        return output
482416
public void renderEntityForm(String entityId, List<CmsTabInfo> tabInfos, Panel context, Element scrollParent) {

        CmsEntity entity = m_entityBackend.getEntity(entityId);
        if (entity != null) {
            boolean initUndo = (m_entity == null) || !entity.getId().equals(m_entity.getId());
            m_entity = entity;
            CmsType type = m_entityBackend.getType(m_entity.getTypeName());
            m_formPanel = new FlowPanel();
            context.add(m_formPanel);
            CmsAttributeHandler.setScrollElement(scrollParent);
            CmsButtonBarHandler.INSTANCE.setWidgetService(m_widgetService);
            if (m_rootHandler == null) {
                m_rootHandler = new CmsRootHandler();
            } else {
                m_rootHandler.clearHandlers();
            }
            m_tabInfos = tabInfos;
            m_formTabs = m_widgetService.getRendererForType(
                type).renderForm(m_entity, m_tabInfos, m_formPanel, m_rootHandler, 0);
            m_validationHandler.registerEntity(m_entity);
            m_validationHandler.setRootHandler(m_rootHandler);
            m_validationHandler.setFormTabPanel(m_formTabs);
            if (initUndo) {
                CmsUndoRedoHandler.getInstance().initialize(m_entity, this, m_rootHandler);
            }
            // trigger validation right away
            m_validationHandler.validate(m_entity);
        }
    }
323804
def populate_tree(self, master, parent, element,from_file=False):
        """"""

        data = WidgetDescr(None, None)
        data.from_xml_node(element)
        cname = data.get_class()
        uniqueid = self.get_unique_id(cname, data.get_id())
        data.set_property('id', uniqueid)

        if cname in builder.CLASS_MAP:
            pwidget = self._insert_item(master, data,from_file=from_file)
            xpath = "./child"
            children = element.findall(xpath)
            for child in children:
                child_object = child.find('./object')
                cwidget = self.populate_tree(pwidget, child, child_object,from_file=from_file)

            return pwidget
        else:
            raise Exception('Class "{0}" not mapped'.format(cname))
72966
function serializeChildren(node) {
	var children = node.childNodes;
	if (children.length === 0) {
		return null;
	}
	
	if (children.length === 1 && children[0].nodeType === 3) {
		return children[0].nodeValue;
	}
	
	var result = "";
	var serializer = new XMLSerializer();
	for (var i = 0; i < children.length; i++) {
		result += serializer.serializeToString(children[i]);
	}
	return result;
}
1053440
function _processNode(node, level) {
        var nodeData = null;
        
        // entity tag
        if (w.isReadOnly === false && node.attr('_entity') && (node.attr('_tag') || node.attr('_note'))) {
            var id = node.attr('name');
            var entity = w.entitiesManager.getEntity(id);
            var type = node.attr('_type');
            var tag = node.attr('_tag');
            if (tag == null) {
                tag = w.schemaManager.mapper.getParentTag(type);
            }
            
            nodeData = {
                text: tag,
                li_attr: {name: id}, // 'class': type}
                state: {opened: level < 3}
            };
            
            if (w.schemaManager.mapper.isEntityTypeNote(type)) {
                var content = w.schemaManager.mapper.getNoteContentForEntity(entity);
                switch($.type(content)) {
                    case 'array':
                        nodeData.children = [];
                        for (var i = 0; i < content.length; i++) {
                            nodeData.children.push({
                                text: content[i],
                                li_attr: {name: id}
                            });
                        }
                        break;
                    case 'string':
                        nodeData.children = [];
                        nodeData.children.push({
                            text: content,
                            li_attr: {name: id}
                        });
                        break;
                    case 'object':
                        if (content.nodeType !== undefined) {
                            var root = $(tag, content).first();
                            
                            var processChildren = function(children, parent, id) {
                                children.each(function(index, el) {
                                    if (parent.children == null) parent.children = [];
                                    var childData = {
                                        text: el.nodeName,
                                        li_attr: {name: id}
                                    };
                                    parent.children.push(childData);
                                    
                                    processChildren($(el).children(), childData, id);
                                });
                            }
                            
                            processChildren(root.children(), nodeData, id);
                        }
                }
            }
            
        // structure tag
        } else if (node.attr('_tag')) {
            var tag = node.attr('_tag');
            if (w.isReadOnly === false || (w.isReadOnly && (tag === w.root || tree.tagFilter.indexOf(tag.toLowerCase()) !== -1))) {
                var id = node.attr('id');
                var info = w.structs[id];
                
                if (info == undefined) {
                    // redo/undo re-added a struct check
                    info = w.deletedStructs[id];
                    if (info != undefined) {
                        w.structs[id] = info;
                        delete w.deletedStructs[id];
                    }
                }
                
                if (info) {
                    var text = info._tag;
                    if (w.isReadOnly) {
                        if (tag === w.root) {
                            text = w.root;// || w.currentDocId;
                        } else {
                            text = w.utilities.getTitleFromContent(node.text());
                        }
                    }
                    nodeData = {
                        text: text,
                        li_attr: {name: id},
                        state: {opened: level < 3}
                    };
                }
            }
        }
        if (nodeData !== null) {
            nodeData.level = level;
            // FIXME we really shouldn't have this hardcoded here
            // manually set the level for CWRC schema to have proper sorting in readOnly mode
            if (w.schemaManager.schemaId === 'cwrcEntry') {
                var subtype = node.attr('subtype');
                if (subtype !== undefined) {
                    nodeData.level = parseInt(subtype);
                }
            }
        }
        
        return nodeData;
    }
103340
function renderChildNodes(props, from, to) {
  const {
    nodeType,
    data,
    collectionLimit,
    circularCache,
    keyPath,
    postprocessValue,
    sortObjectKeys
  } = props;
  const childNodes = [];

  getCollectionEntries(
    nodeType,
    data,
    sortObjectKeys,
    collectionLimit,
    from,
    to
  ).forEach(entry => {
    if (entry.to) {
      childNodes.push(
        <ItemRange
          {...props}
          key={`ItemRange--${entry.from}-${entry.to}`}
          from={entry.from}
          to={entry.to}
          renderChildNodes={renderChildNodes}
        />
      );
    } else {
      const { key, value } = entry;
      const isCircular = circularCache.indexOf(value) !== -1;

      const node = (
        <JSONNode
          {...props}
          {...{ postprocessValue, collectionLimit }}
          key={`Node--${key}`}
          keyPath={[key, ...keyPath]}
          value={postprocessValue(value)}
          circularCache={[...circularCache, value]}
          isCircular={isCircular}
          hideRoot={false}
        />
      );

      if (node !== false) {
        childNodes.push(node);
      }
    }
  });

  return childNodes;
}
1169290
function (el, type) {
		while (el && el.nodeName.toLowerCase() !== type.toLowerCase()) {
			el = el.parentNode;
		}
		return el;
	}
416765
function(tag, attrs, children){
    var el = document.createElement(tag);

    if(attrs != null && typeof attrs === typeof {}){
      Object.keys(attrs).forEach(function(key){
        var val = attrs[key];

        el.setAttribute(key, val);
      });
    } else if(typeof attrs === typeof []){
      children = attrs;
    }

    if(children != null && typeof children === typeof []){
      children.forEach(function(child){
        el.appendChild(child);
      });
    } else if(children != null && typeof children === typeof ''){
      el.appendChild(document.createTextNode(children));
    }

    return el;
  }
1141647
function(elem, child) {
		if (child) {
			var tag = (elem.tagName||'').toLowerCase();
			if (elem.nodeType === 8) { // comment
				if (child.nodeType === 3) { // text node
					elem.nodeValue += child.nodeValue;
				}
			} else if (tag === 'table' && elem.tBodies) {
				if (!child.tagName) {
					// must unwrap documentFragment for tables
					if (child.nodeType === 11) {
						while (child.firstChild) {
							appendDOM(elem, child.removeChild(child.firstChild));
						}
					}
					return;
				}

				// in IE must explicitly nest TRs in TBODY
				var childTag = child.tagName.toLowerCase();// child tagName
				if (childTag && childTag !== 'tbody' && childTag !== 'thead') {
					// insert in last tbody
					var tBody = elem.tBodies.length > 0 ? elem.tBodies[elem.tBodies.length-1] : null;
					if (!tBody) {
						tBody = createElement(childTag === 'th' ? 'thead' : 'tbody');
						elem.appendChild(tBody);
					}
					tBody.appendChild(child);
				} else if (elem.canHaveChildren !== false) {
					elem.appendChild(child);
				}

			} else if (tag === 'style' && document.createStyleSheet) {
				// IE requires this interface for styles
				elem.cssText = child;

			} else if (elem.canHaveChildren !== false) {
				elem.appendChild(child);

			} else if (tag === 'object' &&
				child.tagName && child.tagName.toLowerCase() === 'param') {
					// IE-only path
					try {
						elem.appendChild(child);
					} catch (ex1) {}
					try {
						if (elem.object) {
							elem.object[child.name] = child.value;
						}
					} catch (ex2) {}
			}
		}
	}
70059
private LayoutRoot parseUI(ElementBase root) {
        LayoutRoot ele = new LayoutRoot();

        if (root instanceof ElementDesktop) {
            copyAttributes(root, ele);
        }

        parseChildren(root, ele);
        return ele;
    }
293593
private void  g(Attributes attributes) throws SVGParseException
   {
      debug("<g>");

      if (currentElement == null)
         throw new SVGParseException("Invalid document. Root element must be <svg>");
      SVG.Group  obj = new SVG.Group();
      obj.document = svgDocument;
      obj.parent = currentElement;
      parseAttributesCore(obj, attributes);
      parseAttributesStyle(obj, attributes);
      parseAttributesTransform(obj, attributes);
      parseAttributesConditional(obj, attributes);
      currentElement.addChild(obj);
      currentElement = obj;
   }
916455
function Node(tree, options) {
		this.tree = tree;
		if (options && options.parent) {this.parent = options.parent;}
		if (options && options.hasOwnProperty('key')) { this.key = options.key; }
		this.data = options && options.hasOwnProperty('value') ? [options.value] : [];
	}
674164
protected void _format(EObject obj, IFormattableDocument document) {
		for (EObject child : obj.eContents())
			document.format(child);
	}
1326339
function formatAttributes(outNode, profile) {
	const node = outNode.node;

	return node.attributes.map(attr => {
		if (attr.options.implied && attr.value == null) {
			return null;
		}

		const attrName = profile.attribute(attr.name);
		let attrValue = null;

		// handle boolean attributes
		if (attr.options.boolean || profile.get('booleanAttributes').indexOf(attrName.toLowerCase()) !== -1) {
			if (profile.get('compactBooleanAttributes') && attr.value == null) {
				return ` ${attrName}`;
			} else if (attr.value == null) {
				attrValue = attrName;
			}
		}

		if (attrValue == null) {
			attrValue = outNode.renderFields(attr.value);
		}

		return attr.options.before && attr.options.after
			? ` ${attrName}=${attr.options.before+attrValue+attr.options.after}`
			: ` ${attrName}=${profile.quote(attrValue)}`;
	}).join('');
}
478330
private static void displayInventoryTreeHelper(
      AdUnit root, Map<String, List<AdUnit>> treeMap, int depth) {
    System.out.println(generateTab(depth) + root.getName() + " (" + root.getId() + ")");

    if (treeMap.get(root.getId()) != null) {
      for (AdUnit child : treeMap.get(root.getId())) {
        displayInventoryTreeHelper(child, treeMap, depth + 1);
      }
    }
  }
583266
public static void appendChild(Document doc, Element parentElement, String elementName, String elementValue) {
        Element child = doc.createElement(elementName);
        Text text = doc.createTextNode(elementValue);
        child.appendChild(text);
        parentElement.appendChild(child);
    }
317667
function(root) {
    var tables = root.getElementsByTagName("table");
    for (var i = 0; i < tables.length; i++) {
      var table = tables[i];
      var role = table.getAttribute("role");
      if (role == "presentation") {
        table._readabilityDataTable = false;
        continue;
      }
      var datatable = table.getAttribute("datatable");
      if (datatable == "0") {
        table._readabilityDataTable = false;
        continue;
      }
      var summary = table.getAttribute("summary");
      if (summary) {
        table._readabilityDataTable = true;
        continue;
      }

      var caption = table.getElementsByTagName("caption")[0];
      if (caption && caption.childNodes.length > 0) {
        table._readabilityDataTable = true;
        continue;
      }

      // If the table has a descendant with any of these tags, consider a data table:
      var dataTableDescendants = ["col", "colgroup", "tfoot", "thead", "th"];
      var descendantExists = function(tag) {
        return !!table.getElementsByTagName(tag)[0];
      };
      if (dataTableDescendants.some(descendantExists)) {
        this.log("Data table because found data-y descendant");
        table._readabilityDataTable = true;
        continue;
      }

      // Nested tables indicate a layout table:
      if (table.getElementsByTagName("table")[0]) {
        table._readabilityDataTable = false;
        continue;
      }

      var sizeInfo = this._getRowAndColumnCount(table);
      if (sizeInfo.rows >= 10 || sizeInfo.columns > 4) {
        table._readabilityDataTable = true;
        continue;
      }
      // Now just go by size entirely:
      table._readabilityDataTable = sizeInfo.rows * sizeInfo.columns > 10;
    }
  }