#NEWLINE# def candidate_index( self , node ) : #NEWLINE# #INDENT# '\n        Find and return the promotion candidate and its index.\n\n        Return (None, None) if no valid candidate was found.\n        ' #NEWLINE# index = node . first_child_not_matching_class ( nodes . PreBibliographic ) #NEWLINE# if ( ( index is None ) or ( len ( node ) > ( index + 1 ) ) or ( not isinstance ( node [ index ] , nodes . section ) ) ) : #NEWLINE# #INDENT# return ( None , None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( node [ index ] , index )