Makes a right link or child red

Assumes red $node and $node->right and $node->right->left are black.

@codeCoverageIgnore

@param RedBlackNode $node The node

@return RedBlackNode
485681
protected function moveRedRight(RedBlackNode $node): RedBlackNode
    {
        $this->flipColors($node);
        if ($this->isRed($node->left()->left())) {
            $node = $this->rotateRight($node);
            $this->flipColors($node);
        }

        return $node;
    }
63933
public function enterNode(Node $node)
    {
        if ($node instanceof DirNode) {
            if ($this->skip) {
                throw new DirConstantException();
            }

            return new StringNode($this->getDir());
        }
    }
560965
public function getOtherNode(Node $node)
    {
        if ($node === $this->getStartNode()) {
            return $this->getEndNode();
        }

        return $this->getStartNode();
    }
929845
public static function fromNode(Node $node): self
    {
        return new self($node::schema()->getQName(), (string)$node->get('_id'));
    }
231507
protected function flipColors(RedBlackNode $node): void
    {
        $node->setColor(!($node->color()));
        $node->left()->setColor(!($node->left()->color()));
        $node->right()->setColor(!($node->right()->color()));
    }
145567
public function leaveNode(Node $node)
    {
        if ($node instanceof Expr\ClassConstFetch
            && $node->name === 'class'
        ) {
            $class = $node->class;
            if (strcmp($class->toString(), 'static') === 0
                || strcmp($class->toString(), 'self') === 0
            ) {
                $name = Name::concat($this->namespaceNode, $this->classNode->name);
                return new Scalar\String_(trim($name->toString(), '\\'));
                // return new Expr\FuncCall(new Name('get_class'));
            }
            if ($class->isFullyQualified()) {
                return new Scalar\String_(trim($class->toString(), '\\'));
            }
            $prefix = $this->namespaceNode;
            foreach ($this->importNodes as $import) {
                if (strcmp($class->getFirst(), $import->getLast()) === 0) {
                    $prefix = $import->toString();
                    array_shift($class->parts);
                    break;
                }
            }
            $name = Name::concat($prefix, $class);
            return new Scalar\String_(trim($name->toString(), '\\'));
        }
    }
981609
protected function nodeRemoveRight($key, RedBlackNode $node): RedBlackNode
    {
        if (!$this->isRed($node->right()) && !$this->isRed($node->right()->left())) {
            $node = $this->moveRedRight($node);
        }
        if ($this->comparator->compare($key, $node->key()) === 0) {
            $link = $this->nodeMin($node->right());
            $node->setKey($link->key());
            $node->setValue($link->value());
            $node->setRight($this->nodeRemoveMin($node->right()));
        } else {
            $node->setRight($this->nodeRemove($key, $node->right()));
        }

        return $node;
    }
464154
public function selectNode(string $node = Pool::MASTER): self
    {
        $this->node = $node;

        return $this;
    }
1187630
private function visitNode(\DOMNode $node)
    {
        if ($this->node !== $node) {
            $this->node->appendChild($node);
        }

        return $node;
    }
1343337
protected static function createContentLink($node)
    {
        static::_prepare();
        $url = false;

        // node with external/internal link: get URL from 'route' field
        if (empty($node->text) && !empty($node->route)) {
            $url = static::routeToLink($node->route);
        }

        // site tree content node: create URL for node from visible site tree if this node has original route
        if ($url === false) {
            $url = Url::toRoute([static::$_routeActionView, 'id' => $node->id]);
            $parts = parse_url($url);
            if (!empty($parts['path'])) {
                $url = $parts['path'];
                if (strstr($url, static::$_routeActionView)) { // it's fake link contain action UID and GET-parameter "id={$id}"
                    $url = false;
                }
            }
        }

        // node has content but any links yet: create URL for node out of visible site tree (submenu tree)
        if ($url === false && empty($node->route) && !empty($node->text)) {
            $url = Url::toRoute([static::$_routeActionShow, 'id' => $node->id, 'slug' => $node->slug]);
        }

        return $url;
    }
294086
public function getValueForNode(Node $node)
    {
        if ($node->isNamed()) {
            return $node->getUri();
        } elseif ($node->isLiteral()) {
            return $node->getValue();
        } elseif ($node->isBlank()) {
            return $node->getBlankId();
        } else {
            return null;
        }
    }
1121022
public function &detach(Node $node)
    {
        foreach ($this->links as $linked_node) {
            if ($linked_node == $node) {
                $this->links->detach($node);
            }
        }

        return $this;
    }
1264936
public function leaveNode(Node $node) {
        if ($this->phpClass instanceof PhpClass) {
            if ($node instanceof Class_) {
                if (!empty($node->extends) && count($node->extends->parts) > 0) {
                    $this->phpClass->setExtends(implode('\\', $node->extends->parts));
                }

                if (!empty($node->implements) && is_array($node->implements)) {
                    foreach ($node->implements as $implements) {
                        $this->phpClass->setImplements(implode('\\', $implements->parts));
                    }
                }

                if ($node->type === 0) {
                    $this->phpClass->setClassType(PhpClass::TYPE_CLASS);
                } elseif ($node->type === 16) {
                    $this->phpClass->setClassType(PhpClass::TYPE_ABSTRACT_CLASS);
                } elseif ($node->type === 32) {
                    $this->phpClass->setClassType(PhpClass::TYPE_FINAL_CLASS);
                }

                $this->phpClass->setClass($node->name);
            } elseif ($node instanceof Interface_) {
                if (!empty($node->extends) && is_array($node->extends)) {
                    foreach ($node->extends as $implements) {
                        $this->phpClass->setImplements(implode('\\', $implements->parts));
                    }
                }

                $this->phpClass->setClassType(PhpClass::TYPE_INTERFACE);
                $this->phpClass->setClass($node->name);
            } elseif ($node instanceof Trait_) {
                $this->phpClass->setClassType(PhpClass::TYPE_TRAIT);
                $this->phpClass->setClass($node->name);
            } elseif ($node instanceof Namespace_) {
                $this->phpClass->setNamespace(implode('\\', $node->name->parts));
            } elseif ($node instanceof TraitUse) {
                if (!empty($node->traits) && is_array($node->traits)) {
                    foreach ($node->traits as $trait) {
                        $this->phpClass->setTraits(implode('\\', $trait->parts));
                    }
                }
            }
        }
    }
1189555
public function render_node(node $node) {
        $return = '';
        if (is_object($node->url)) {
            $header = \html_writer::link($node->url, $node->title);
        } else {
            $header = $node->title;
        }
        $icon = $node->icon;
        if (!empty($icon)) {
            $header .= $this->render($icon);
        }
        $content = $node->content;
        $classes = $node->classes;
        if (!empty($content)) {
            if ($header) {
                // There is some content to display below this make this a header.
                $return = \html_writer::tag('dt', $header);
                $return .= \html_writer::tag('dd', $content);

                $return = \html_writer::tag('dl', $return);
            } else {
                $return = \html_writer::span($content);
            }
            if ($classes) {
                $return = \html_writer::tag('li', $return, array('class' => 'contentnode ' . $classes));
            } else {
                $return = \html_writer::tag('li', $return, array('class' => 'contentnode'));
            }
        } else {
            $return = \html_writer::span($header);
            $return = \html_writer::tag('li', $return, array('class' => $classes));
        }

        return $return;
    }
301232
private RedBlackTreeNode<Key, Value> rotateRight(RedBlackTreeNode<Key, Value> h) {
	// assert (h != null) && h.getLeft().isRed();
	RedBlackTreeNode<Key, Value> x = h.getLeft();
	h.setLeft(x.getRight());
	x.setRight(h);
	x.setColor(x.getRight().getColor());
	x.getRight().setColor(RED);
	x.setSize(h.getSize());
	h.setSize(size(h.getLeft()) + size(h.getRight()) + 1);
	return x;
    }
483414
protected function nodeSet($key, $value, ?RedBlackNode $node): RedBlackNode
    {
        if ($node === null) {
            return new RedBlackNode($key, $value, 1, RedBlackNode::RED);
        }

        $comp = $this->comparator->compare($key, $node->key());

        if ($comp < 0) {
            $node->setLeft($this->nodeSet($key, $value, $node->left()));
        } elseif ($comp > 0) {
            $node->setRight($this->nodeSet($key, $value, $node->right()));
        } else {
            $node->setValue($value);
        }

        return $this->balanceOnInsert($node);
    }
624637
public function enterNode(Node $node)
    {
        if ($node instanceof Namespace_) {
            $this->resetContext($node->name);
        }

        $this->recordDoc($node->getAttribute('comments', []));

        return $node;
    }