private function checkType($oldType, $newType, NodePath $nodePath) : string
    {
        if (!is_null($oldType) && ($newType !== $oldType) && ($newType !== 'null') && ($oldType !== 'null')) {
            throw new JsonParserException(
                "Data in '$nodePath' contains incompatible data types '$oldType' and '$newType'."
            );
        }
        return $newType;
    }