from typing import Optional
from typing import Sequence
import difflib


def best_match(needle: Optional[str], haystack: Sequence[str]) -> Optional[str]:
    """Finds the closest match of a given string in a list of potential strings."""
    if not needle or not haystack:
        return None

    matches = difflib.get_close_matches(needle, haystack, n=1)
    return matches[0] if matches else None