Find root which is common for all `elements`.

    Args:
        elements (list): List of double-linked HTMLElement objects.

    Returns:
        list: Vector of HTMLElement containing path to common root.
541864
def find_common_root(elements):
    
    if not elements:
        raise UserWarning("Can't find common root - no elements suplied.")

    root_path = el_to_path_vector(elements.pop())

    for el in elements:
        el_path = el_to_path_vector(el)

        root_path = common_vector_root(root_path, el_path)

        if not root_path:
            raise UserWarning(
                "Vectors without common root:\n%s" % str(el_path)
            )

    return root_path
320432
protected Collection<AbstractElement> getElementsToParse(AbstractElement root,
			List<AbstractElement> handledUnorderedGroupElements) {
		if (root instanceof UnorderedGroup) {
			if (handledUnorderedGroupElements.isEmpty())
				return ((CompoundElement) root).getElements();
			List<AbstractElement> result = Lists.newArrayList(root);
			for (AbstractElement child : ((UnorderedGroup) root).getElements()) {
				if (!handledUnorderedGroupElements.contains(child)) {
					result.add(child);
				}
			}
			return result;
		}
		return getElementsToParse(root);
	}
845481
def element(self, inp=None):
        
        for set in self.sets:
            try:
                return set.element(inp)
            except NotImplementedError:
                pass
        raise NotImplementedError('`element` not implemented for any of the '
                                  'subsets')
586410
private Element findRootFolderElement( Document dom )
    {
        NodeList list = dom.getElementsByTagNameNS( "*", "folder" );

        final String localRootId = getRootId(); // cache it also in this method

        for ( int i = 0; i < list.getLength(); i++ ) {
            Element e = ( Element ) list.item( i );
            if ( e.getAttribute( "id" ).equals( localRootId ) ) {
                return e;
            }
        }
        throw new CStorageException( "Could not find root folder with id=" + localRootId );
    }
819852
def _get_elements_property(parent_to_parse, element_path, prop_name):
    

    parent_element = get_element(parent_to_parse)

    if parent_element is None:
        return []

    if element_path and not element_exists(parent_element, element_path):
        return []

    if not element_path:
        texts = getattr(parent_element, prop_name)
        texts = texts.strip() if isinstance(texts, string_types) else texts
        texts = [texts] if texts else []
    else:
        texts = [t for t in (
            prop.strip() if isinstance(prop, string_types) else prop
            for prop in (getattr(node, prop_name) for node in parent_element.findall(element_path)) if prop
        ) if t]

    return texts
861389
def _find_web_element(self):
        """"""
        if not self._web_element or not self.config.getboolean_optional('Driver', 'save_web_element'):
            # If the element is encapsulated we use the shadowroot tag in yaml (eg. Shadowroot: root_element_name)
            if self.shadowroot:
                if self.locator[0] != By.CSS_SELECTOR:
                    raise Exception('Locator type should be CSS_SELECTOR using shadowroot but found: '
                                    '%s'.format(self.locator[0]))
                # querySelector only support CSS SELECTOR locator
                self._web_element = self.driver.execute_script('return document.querySelector("%s").shadowRoot.'
                                                               'querySelector("%s")' % (self.shadowroot,
                                                                                        self.locator[1]))
            else:
                # Element will be finded from parent element or from driver
                base = self.utils.get_web_element(self.parent) if self.parent else self.driver
                # Find elements and get the correct index or find a single element
                self._web_element = base.find_elements(*self.locator)[self.order] if self.order else base.find_element(
                    *self.locator)
259682
private static <E extends Element> List<E> findTopLevelElementsRecurse(Class<E> elementType, Node node, List<E> matches) {
		for(Element elem : node.getChildElements()) {
			if(elementType.isInstance(elem)) {
				// Found match
				if(matches == null) matches = new ArrayList<>();
				matches.add(elementType.cast(elem));
			} else {
				// Look further down the tree
				matches = findTopLevelElementsRecurse(elementType, elem, matches);
			}
		}
		return matches;
	}
798575
public static Element getChild( Element root, String name )
    {
        if( null == root )
        {
            return null;
        }
        NodeList list = root.getElementsByTagName( name );
        int n = list.getLength();
        if( n < 1 )
        {
            return null;
        }
        return (Element) list.item( 0 );
    }
411858
private List<XsdElement> getAllElementsRecursively(XsdAbstractElement element) {
        List<XsdElement> allGroupElements = new ArrayList<>();
        List<XsdAbstractElement> directElements = element.getXsdElements().collect(Collectors.toList());

        allGroupElements.addAll(
                directElements.stream()
                        .filter(elem1 -> elem1 instanceof XsdElement)
                        .map(elem1 -> (XsdElement) elem1)
                        .collect(Collectors.toList()));

        for (XsdAbstractElement elem : directElements) {
            if ((elem instanceof XsdMultipleElements || elem instanceof XsdGroup) && elem.getXsdElements() != null) {
                allGroupElements.addAll(getAllElementsRecursively(elem));
            }
        }

        return allGroupElements;
    }
1368716
def find_element_by_xpath(self, xpath):
        
        from sdklib.html.elem import Elem5lib

        return Elem5lib(self.html_obj.find(self._convert_xpath(xpath)))
759198
def _element(cls):
        '''    '''
        if not cls.__is_selector():
            raise Exception("Invalid selector[%s]." %cls.__control["by"])
        
        driver = Web.driver
        try:            
            elements = WebDriverWait(driver, cls.__control["timeout"]).until(lambda driver: getattr(driver,"find_elements")(cls.__control["by"], cls.__control["value"]))
        except:                        
            raise Exception("Timeout at %d seconds.Element(%s) not found." %(cls.__control["timeout"],cls.__control["by"]))
        
        if len(elements) < cls.__control["index"] + 1:                    
            raise Exception("Element [%s]: Element Index Issue! There are [%s] Elements! Index=[%s]" % (cls.__name__, len(elements), cls.__control["index"]))
        
        if len(elements) > 1:              
            print("Element [%s]: There are [%d] elements, choosed index=%d" %(cls.__name__,len(elements),cls.__control["index"]))
        
        elm = elements[cls.__control["index"]]
        cls.__control["index"] = 0        
        return elm
592073
function _findDistributionRoot(element) {
    var root = element.shadyRoot;
    while (element && this._elementNeedsDistribution(element)) {
      root = element.getRootNode();
      element = root && root.host;
    }
    return root;
  }
1061279
def find_stack_elements(self, module, module_name="", _visited_modules=None):
        
        from types import ModuleType
        if _visited_modules is None: _visited_modules = []
        _visited_modules.append(module)
        #
        elements = []
        for el_name in dir(module):
            the_el = module.__getattribute__(el_name)
            if isinstance(the_el, ModuleType):
                # Recursively go into the module
                if the_el in _visited_modules:
                    continue
                elements = elements + self.find_stack_elements(the_el, module_name + el_name + ".", _visited_modules)
            elif isinstance(the_el, StackElement):
                # Add to list
                elements.append((module_name, el_name, the_el))
        return elements
188509
def find(self, name):
        
        elt = self.element.find('s3:{}'.format(name), _S3_NS)
        return S3Element(self.root_name, elt) if elt is not None else None
395366
def element_to_extension_element(element):
    

    exel = ExtensionElement(element.c_tag, element.c_namespace,
                            text=element.text)

    exel.attributes.update(element.extension_attributes)
    exel.children.extend(element.extension_elements)

    for xml_attribute, (member_name, typ, req) in \
            iter(element.c_attributes.items()):
        member_value = getattr(element, member_name)
        if member_value is not None:
            exel.attributes[xml_attribute] = member_value

    exel.children.extend([element_to_extension_element(c) for c in
                          element.children_with_values()])

    return exel
738468
public static List<Element> getAllChildElements(Element parent) {
        List<Element> result;
        NodeList nodes;
        int i;
        int max;
        Node node;

        result = new ArrayList<>();
        nodes = parent.getChildNodes();
        max = nodes.getLength();
        for (i = 0; i < max; i++) {
            node = nodes.item(i);
            if (node instanceof Element) {
                result.add((Element) node);
            }
        }
        return result;
    }
864385
def root(self):
        
        if self.is_root:
            return self
        return self.adapter.wrap_node(
            self.adapter.impl_root_element, self.adapter.impl_document,
            self.adapter)