import ast


def get_attr(node, name):
    """get the attribute of node or None if the attribute doesn't exist

    Args:
        node (ast.AST): node whose attribute is going to be check.
        name (str): name of the attribute whose existence is being tested.
    Returns:
        str: in case the docstring was requested.
        ast.AST: in case the requested attribute is an instance of AST.
        None: if the attibute was not found.
        object: any type that the attribute may have.
    """
    if name == 'doc':
        return str(ast.get_docstring(node, clean=True))
    if hasattr(node, name):
        return getattr(node, name)