def parent_type(node: Optional[LN]) -> Optional[NodeType]:
    """
    Returns:
        @node.parent.type, if @node is not None and has a parent.
            OR
        None, otherwise.
    """
    if node is None or node.parent is None:
        return None

    return node.parent.type

    Returns:
        @node.parent.type, if @node is not None and has a parent.
            OR
        None, otherwise.
    
src/black/nodes.py