from typing import Mapping


def stream_matches_language(stream: Mapping, language: str) -> bool:
    """Check if a stream matches given language."""
    language = language.lower()
    try:
        tags = stream["tags"]
        return bool(
            tags["language"].lower() == language
            or tags["title"].lower() == language
        )
    except KeyError:
        return False