from typing import Dict


def find(content: Dict, reference: str, extern: bool = False) -> bool:
    """Check if reference is used in the provided content.

    Arguments
    ---------
    content
        OpenAPI document to be cleaned up.
    reference
        Internal reference to be searched.
    extern
        Flag about searching in external references too.

    Returns
    -------
    Flag determining presence of the reference in the content.

    """
    if isinstance(content, list):
        for item in content:
            if find(item, reference, extern):
                return True
    if isinstance(content, dict):
        for key, value in content.items():
            if key == '$ref':
                if value.endswith(reference) if extern \
                    else value == reference:
                    return True
            if find(value, reference, extern):
                return True
    return False