Get the next sibling of the given element type
@param $element Reference element
@param $elementType Element type (e.g. XML_ELEMENT_NODE)
@return \DomElement
321024
public static function getNextSiblingOfType(\DOMElement $element, $elementType) {
    $nextSibling = $element->nextSibling;
    while ($nextSibling && $nextSibling->nodeType != $elementType) {
      $nextSibling = $nextSibling->nextSibling;
    }
    return $nextSibling;
  }
914107
protected function NextItem()
	{
		// return null;
		$nodeTest = XmlQualifiedNameTest::Create();

		while ( true )
		{
			if ( ! $this->iterator->MoveNext() )
			{
				return null;
			}

			$node = $this->iterator->getCurrent();

			// An element with children cannot be an ID
			if ( $node->getHasChildren() ) continue;

			// Is this element a type?
			// $info = $node->getSchemaInfo();
			$type = $this->types->getElement( $node->LocalName, $node->Prefix == "" ? null : $node->Prefix );
			if ( $type )
			{
				return CoreFuncs::CloneInstance( $node );
			}
			else
			{
				// Look at the attributes
				if ( ! $node->getHasAttributes() ) continue;
				$attribs = AttributeNodeIterator::fromNodeTest( $this->context, $nodeTest, XPath2NodeIterator::Create( $node ) );
				foreach ( $attribs as $attribute )
				{
					$info = $attribute->getSchemaInfo();
					$type = $this->types->getAttribute( $attribute->LocalName, $info->Prefix == "" ? SCHEMA_PREFIX : $info->Prefix );
					if ( ! $type ) continue;
					foreach ( $type['types'] as $type )
					{
						if ( $type['prefix'] != SCHEMA_PREFIX ||
							 $type['name'] != ( $this->type ? "IDREF" : "ID" ) ||
							 ! in_array( $attribute->getValue(), $this->IDRef )
						) continue;
						return CoreFuncs::CloneInstance( $this->type ? $attribute : $node );
					}
					// if ( $attribute->LocalName == "anId" && in_array( $attribute->getValue(), $this->IDRef ) )
					// {
					// 	return CoreFuncs::CloneInstance( $node );
					// }
				}
			}
		}
	}
131713
public function createElementSource(Elementtype $elementtype)
    {
        $xmlDumper = new XmlDumper();

        $elementSource = new ElementSource();
        $elementSource
            ->setElementtypeId($elementtype->getId())
            ->setElementtypeRevision($elementtype->getRevision())
            ->setType($elementtype->getType())
            ->setXml($xmlDumper->dump($elementtype))
            ->setElementtype($elementtype)
            ->setImportedAt(new \DateTime());

        $this->elementSourceManager->updateElementSource($elementSource);

        return $elementSource;
    }
700022
def get_next_tag(cls, el):
        """"""

        sibling = el.next_sibling
        while not cls.is_tag(sibling) and sibling is not None:
            sibling = sibling.next_sibling
        return sibling
1205676
function (dom, prev, next) {
      var sibling, tmpSibling, elementUtils = new ElementUtils(dom);

      // Check if next/prev exists and that they are elements
      if (prev && next) {
        // If previous sibling is empty then jump over it
        prev = findElementSibling(prev, 'previousSibling');
        next = findElementSibling(next, 'nextSibling');

        // Compare next and previous nodes
        if (elementUtils.compare(prev, next)) {
          // Append nodes between
          for (sibling = prev.nextSibling; sibling && sibling !== next;) {
            tmpSibling = sibling;
            sibling = sibling.nextSibling;
            prev.appendChild(tmpSibling);
          }

          dom.remove(next);

          each(Tools.grep(next.childNodes), function (node) {
            prev.appendChild(node);
          });

          return prev;
        }
      }

      return next;
    }
502331
protected function getSubElement($element)
    {
        if ($element === BaseRange::INFINITY_MIN) {
            return BaseRange::INFINITY_MIN;
        } elseif ($element === BaseRange::INFINITY_MAX) {
            return BaseRange::INFINITY_MAX;
        } elseif ($element === '') {
            return null;
        }

        return new \DateTime($element);
    }
63072
def next_element
      element = next_sibling
      element = element.next_sibling until element.nil? or element.kind_of? Element 
      return element
    end
366170
protected function sibling($node, $siblingDir = 'nextSibling')
    {
        $nodes = [];

        $currentNode = $this->getNode(0);
        do {
            if ($node !== $currentNode && XML_ELEMENT_NODE === $node->nodeType) {
                $nodes[] = $node;
            }
        } while ($node = $node->$siblingDir);

        return $nodes;
    }
1227643
private function getFirstChild(\DOMDocument $document)
    {
        foreach ($document->childNodes as $child) {
            if ($child instanceof \DOMElement) {
                return $child;
                // @codeCoverageIgnoreStart
            }
        }

        return false;
        // @codeCoverageIgnoreEnd
    }
1023461
public function findAllowedChildren(Elementtype $elementtype)
    {
        $elementtypes = [];
        foreach ($this->viabilityManager->findAllowedChildren($elementtype) as $viability) {
            $viabilityElementtype = $this->elementSourceManager->findElementtype($viability->getElementtypeId());
            if ($viabilityElementtype) {
                $elementtypes[] = $viabilityElementtype;
            }
        }

        return $elementtypes;
    }
257985
def nextElementSibling(self) -> Optional[AbstractNode]:
        
        if self.parentNode is None:
            return None
        siblings = self.parentNode.childNodes
        for i in range(siblings.index(self) + 1, len(siblings)):
            n = siblings[i]
            if n.nodeType == Node.ELEMENT_NODE:
                return n
        return None
446017
public static function arrayOf(IType $elementType) : ArrayType
    {
        $elementTypeString = $elementType->asTypeString();

        if (!isset(self::$arrays[$elementTypeString])) {
            self::$arrays[$elementTypeString] = new ArrayType($elementType);
        }

        return self::$arrays[$elementTypeString];
    }
1071571
private function getFieldElement($element)
    {
        $element = $this->getElement($element);
        while (null !== $element && !$element->hasClass('field')) {
            $element = $element->getParent();
        }

        return $element;
    }
361266
protected function unmarshall(DOMElement $element)
    {
        $component = new Br();

        if (($xmlBase = self::getXmlBase($element)) !== false) {
            $component->setXmlBase($xmlBase);
        }

        $this->fillBodyElement($component, $element);

        return $component;
    }
534035
protected function element($element = null)
    {
        return is_null($element)
            ? $this->element
            : ($this->element = $element);
    }
409991
protected function unmarshall(DOMElement $element)
    {
        $node = $element->cloneNode(true);
        
        return new Sub($element->ownerDocument->saveXML($node));
    }
267650
public function siblings($selector = null): NodeList {
        $results = $this->collection()->reduce(function($carry, $node) use ($selector) {
            return $carry->merge(
                $node->precedingAll($selector)->merge(
                    $node->followingAll($selector)
                )
            );
        }, $this->newNodeList());

        return $results;
    }