def session_key(tree) -> str:
    """
    Find the session key in an XML tree.

    Args:
        tree (XML Tree): XML Tree retrieved from login url.
    Returns:
        (str): Today's API key or NoneType on failure.
    """
    root = tree.getroot()
    child = root.find('user')
    sid = child.find('id').text

    # Check for errors
    if sid is None:
        child = root.find('pdheaders')
        message = child.find('pdheader1').text
        raise Exception(f"PublicData login failure: {message}")

    # We had a successful login
    session_id = child.find('sessionid').text
    return session_id