Recursively parse child tags until match is found
490843
def parse_children(parent):
    """"""

    components = []
    for tag in parent.children:
        matched = parse_tag(tag)
        if matched:
            components.append(matched)
        elif hasattr(tag, 'contents'):
            components += parse_children(tag)
    return components
1213914
def _child_list(element, child_tagname):
    
    xpath = './%s' % child_tagname
    return element.xpath(xpath, namespaces=nsmap)
110865
function parse_children(lines, parent_node_names)
{
	// preprocess the lines (filter out comments, blank lines, etc)
	lines = filter_lines_for_parsing(lines)

	// return empty object if there are no lines to parse
	if (lines.length === 0)
	{
		return {}
	}

	// parse each child node's lines
	return split_lines_by_child_nodes(lines).map(function(lines)
	{
		// the first line is this child node's name (or names)
		const declaration_line = lines.shift()

		// check for excessive indentation of the first child style class
		if (declaration_line.tabs !== 0)
		{
			throw new Error(`Excessive indentation (${declaration_line.tabs} more "tabs" than needed) at line ${declaration_line.index}: "${declaration_line.original_line}"`)
		}

		// style class name declaration
		const declaration = declaration_line.line

		// child nodes' names
		const names = declaration.split(',').map(name => name.trim())

		// style class nesting validation
		validate_child_style_class_types(parent_node_names, names)

		// parse own CSS styles and recursively parse all child nodes
		const style_json = parse_style_class(lines, names)

		// generate style json for this child node (or child nodes)
		return names.map(function(node_declaration)
		{
			// parse this child node name
			const { name, is_a_modifier } = parse_node_name(node_declaration)

			// clone the style JSON object for this child node
			const json = extend({}, style_json)

			// set the modifier flag if it's the case
			if (is_a_modifier)
			{
				json._is_a_modifier = true
			}

			// this child node's style JSON object
			return { name, json }
		})
	})
	// convert an array of arrays to a flat array
	.reduce(function(array, child_array)
	{
		return array.concat(child_array);
	}, 
	[])
	// combine all the child nodes into a single JSON object
	.reduce(function(nodes, node)
	{
		// if style already exists for this child node, extend it
		if (nodes[node.name])
		{
			extend(nodes[node.name], node.json)
		}
		else
		{
			nodes[node.name] = node.json
		}
		
		return nodes
	}, 
	{})
}
282266
def _child(element, child_tagname):
    
    xpath = './%s' % child_tagname
    matching_children = element.xpath(xpath, namespaces=nsmap)
    return matching_children[0] if len(matching_children) else None
375093
def find(soup, name=None, attrs=None, recursive=True, text=None, **kwargs):
    
    tags = find_all(
        soup, name, attrs or {}, recursive, text, 1, **kwargs
    )
    if tags:
        return tags[0]
1166705
def match_empty(self, el):
        """"""

        is_empty = True
        for child in self.get_children(el, tags=False):
            if self.is_tag(child):
                is_empty = False
                break
            elif self.is_content_string(child) and RE_NOT_EMPTY.search(child):
                is_empty = False
                break
        return is_empty
642883
def match_future_child(self, parent, relation, recursive=False):
        """"""

        match = False
        children = self.get_descendants if recursive else self.get_children
        for child in children(parent, no_iframe=self.iframe_restrict):
            match = self.match_selectors(child, relation)
            if match:
                break
        return match
713081
function matchToHolders(match, tag) {
  return object(match.map(function(val, index) {
    return [tag+":"+index, val];
  }));
}
189825
def _get_tag_match(self, ele, tree):
        
        if tree in [None, []]:
            return [ele]

        res = []
        t = tree[0]
        branch = tree[1:]
        attributes = {}

        for attr in t:
            if isinstance(t[attr], dict):
                if t[attr].get("type", None) == "reg":
                    t[attr] = re.compile(t[attr]['reg'])

        attributes.update(t)

        if "name" in attributes:
            del attributes['name']
        if "text" in attributes:
            del attributes['text']
        if "recursive" in attributes:
            del attributes['recursive']
        if "[]" in attributes:
            del attributes['[]']

        possibles = ele.find_all(
            t.get('name', None),
            text=t.get('text', None),
            attrs=attributes,
            recursive=t.get('recursive', True)
        )

        if not possibles:
            return None
        else:
            pass

        if "[]" in t:
            try:
                possibles = eval("possibles[{}]".format(t["[]"]))
            except:
                # no possibles
                return None

        if not isinstance(possibles, list):
            possibles = [possibles]

        for a in possibles:
            match = self._get_tag_match(a, branch)

            if match:
                res.extend(match)

        if not res:
            return None
        else:
            return res
1004560
function handle(match, position, parent, phrase) {
        var index = list.indexOf(phrase)
        var pattern = byIndex[index]
        var id = pattern.id

        if (!(id in matches)) {
          matches[id] = []
        }

        matches[id].push({
          type: pattern.inconsiderate[phrase],
          parent: parent,
          nodes: match,
          start: position,
          end: position + match.length - 1
        })
      }
784036
def find(self, tag_name, params=None, fn=None, case_sensitive=False):
        
        return [
            x for x in self.findAll(tag_name, params, fn, case_sensitive)
            if not x.isEndTag()
        ]
951372
def _get_unique_child(xtag, eltname):
    """"""
    try:
        results = xtag.findall(eltname)
        if len(results) > 1:
            raise Exception("Multiple elements found where 0/1 expected")
        elif len(results) == 1:
            return results[0]
        else:
            return None
    except Exception:
        return None
641189
def parse_rsc_html(htmlstring):
    """"""
    converted = UnicodeDammit(htmlstring)
    if not converted.unicode_markup:
        raise UnicodeDecodeError('Failed to detect encoding, tried [%s]')
    root = fromstring(htmlstring, parser=HTMLParser(recover=True, encoding=converted.original_encoding))
    # Add p.otherpara tags around orphan text
    newp = None
    for child in root.get_element_by_id('wrapper'):
        if newp is not None:
            if child.tag in BLOCK_ELEMENTS or child.get('id', '').startswith('sect') or child.getnext() is None:
                child.addprevious(newp)
                newp = None
            else:
                newp.append(child)
        if newp is None and child.tag in BLOCK_ELEMENTS and child.tail and child.tail.strip():
            newp = Element('p', **{'class': 'otherpara'})
            newp.text = child.tail
            child.tail = ''
    return root
38085
def find_event_parent_with_event_child(self, parent_name, child_name):
        """"""
        G = self.G
        matches = []
        for n in G.node.keys():
            if G.node[n]['is_event'] and G.node[n]['type'] == parent_name:
                children = G.successors(n)
                for child in children:
                    if G.node[child]['is_event'] and \
                            G.node[child]['type'] == child_name:
                        matches.append((n, child))
                        break
        return list(set(matches))
1224012
def parse(scanner, rules, scope = ParserScope.empty)
      for child in children
        if r = child.parse(scanner, rules, scope)
          return r
        end
      end
      false
    end
157486
function parseChildrenProperties( root, libs, com, indent ) {
  if (!Array.isArray( root.children )) {
    root.children = [ ];
  }
  root.children.forEach( function( child ) {
    debugger;
    if ( child.type != libs.Tree.TAG ) {
      return;
    }
    libs.compileChildren( child );

    if ( typeof child.attribs === 'undefined' ) {
      child.attribs = {};
    }
    if ( child.attribs.json === null ) {
      parsePropertyJSON( child, libs, com );
    }
    else {
      // By default, this is a list.
      parsePropertyList( child, libs, com, indent + "  " );
    }
  });
}
25634
def match_nth_tag_type(self, el, child):
        """"""

        return(
            (self.get_tag(child) == self.get_tag(el)) and
            (self.get_tag_ns(child) == self.get_tag_ns(el))
        )