from typing import Optional
from typing import Tuple
import re


def _parse_addr(addr: str, allow_wildcard: bool = False) -> Optional[Tuple[str, str]]:
    """Safely parse an email, returning first component and domain."""
    m = re.match(
        (
            r'([a-zA-Z0-9\-_\+\.]+)' +
            ('?' if allow_wildcard else '') +
            r'@([a-zA-Z0-9\-_\+\.]+)$'
        ),
        addr,
    )
    if not m:
        return None
    name, domain = m.group(1), m.group(2)
    if '.' in domain:
        return name, domain

    return None