<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://microformats.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=LimonOrc4t</id>
	<title>Microformats Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://microformats.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=LimonOrc4t"/>
	<link rel="alternate" type="text/html" href="https://microformats.org/wiki/Special:Contributions/LimonOrc4t"/>
	<updated>2026-04-25T06:43:34Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.38.4</generator>
	<entry>
		<id>https://microformats.org/wiki/index.php?title=algorithm-nearest-in-parent&amp;diff=35622</id>
		<title>algorithm-nearest-in-parent</title>
		<link rel="alternate" type="text/html" href="https://microformats.org/wiki/index.php?title=algorithm-nearest-in-parent&amp;diff=35622"/>
		<updated>2008-12-19T17:58:39Z</updated>

		<summary type="html">&lt;p&gt;LimonOrc4t: liraccvie&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;taerrelgetra&lt;br /&gt;
This algorithm will return all the elements in a DOM that meet the &amp;lt;code&amp;gt;condition_test&amp;lt;/code&amp;gt; by checking each node in the parent hierarchy above the &amp;lt;code&amp;gt;start_element&amp;lt;/code&amp;gt; on up. Once a result is found at any level of the parent hierarchy, we stop checking.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
def nearest_in_parent(start_element, condition_test):&lt;br /&gt;
  p = start_element.parent&lt;br /&gt;
  while p:&lt;br /&gt;
    as = []&lt;br /&gt;
    for c in ordered_depth_first_element_iter(p):&lt;br /&gt;
      if condition_test(c):&lt;br /&gt;
        as.append(c)&lt;br /&gt;
&lt;br /&gt;
    if as:&lt;br /&gt;
      return as&lt;br /&gt;
&lt;br /&gt;
    p = p.parent&lt;br /&gt;
&lt;br /&gt;
  return None&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>LimonOrc4t</name></author>
	</entry>
</feed>