#NEWLINE# def ancestor( self , n = 1 ) : #NEWLINE# #INDENT# ' Retrieve an ancestor node from the internal stack.\n\n        Parameters\n        ----------\n        n : int, optional\n            The depth of the target parent in the ancestry. The default\n            is 1 and indicates the parent of the active node.\n\n        Returns\n        -------\n        result : ASTNode or None\n            The desired ancestor node, or None if the index is out of\n            range.\n\n        ' #NEWLINE# try : #NEWLINE# #INDENT# result = self . _node_stack [ ( ( - 1 ) - n ) ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# result = None #NEWLINE# #UNINDENT# return result