#NEWLINE# def _dfs( self , node , visited = None ) : #NEWLINE# #INDENT# if ( visited is None ) : #NEWLINE# #INDENT# visited = set ( [ ] ) #NEWLINE# #UNINDENT# if ( node in visited ) : #NEWLINE# #INDENT# return visited #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# visited . add ( node ) #NEWLINE# for child in node . children ( ) : #NEWLINE# #INDENT# self . _dfs ( child , visited ) #NEWLINE# #UNINDENT# for parent in node . parents ( ) : #NEWLINE# #INDENT# self . _dfs ( parent , visited ) #NEWLINE# #UNINDENT# #UNINDENT# return self