import yaml


def _get_metadata(tokens):
    """Find and parse metadata (if present)."""
    for token in tokens:
        if token.type == "front_matter":
            return yaml.safe_load(token.content)
    return {}