public function getTokenOfKindSibling($index, $direction, array $tokens = [], $caseSensitive = true)
    {
        if (!self::isLegacyMode()) {
            $tokens = array_filter($tokens, function ($token) {
                return $this->isTokenKindFound($this->extractTokenKind($token));
            });
        }

        if (!\count($tokens)) {
            return null;
        }

        while (true) {
            $index += $direction;

            if (!$this->offsetExists($index)) {
                return null;
            }

            $token = $this[$index];

            if ($token->equalsAny($tokens, $caseSensitive)) {
                return $index;
            }
        }
    }