(tree: ast.AST, node: ast.AST,
                          type_: Type[T])
Get a closest parent of passed type.
Get a closest parent of passed type.
Get a closest parent of passed type .
def get_closest_parent_of(tree: ast.AST, node: ast.AST,
                          type_: Type[T]) -> T:
    """Get a closest parent of passed type."""
    parent = node

    while True:
        parent = get_parent(tree, parent)

        if isinstance(parent, type_):
            return parent
def get_closest_parent_of ( tree : ast . AST , node : ast . AST , type_ : Type [ T ] ) -> T : parent = node while True : parent = get_parent ( tree , parent ) if isinstance ( parent , type_ ) : return parent