#NEWLINE# def findTextPoint( node , offset ) : #NEWLINE# #INDENT# '\n    If the found range is not on a text node, this finds the cooresponding\n    text node to where the selection is.  If it is on a text node, just\n    directly creates the endpoint from it.\n\n    @param node node returned as an endpoint of a range\n    @param offset offset returned to the endpoint of a range\n    @return A range end point with a proper (or None) text node\n    ' #NEWLINE# if ( DOM . getNodeType ( node ) == DOM . TEXT_NODE ) : #NEWLINE# #INDENT# res = RangeEndPoint ( node , offset ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dirn = ( offset >= DOM . getChildCount ( node ) ) #NEWLINE# child = ( ( ( DOM . getChildCount ( node ) == 0 ) and node ) or DOM . getChild ( node , ( ( dirn and ( offset - 1 ) ) or offset ) ) ) #NEWLINE# text = RangeUtil . getAdjacentTextElement ( child , dirn ) #NEWLINE# if ( text is None ) : #NEWLINE# #INDENT# dirn = ( not dirn ) #NEWLINE# text = RangeUtil . getAdjacentTextElement ( child , dirn ) #NEWLINE# #UNINDENT# res = RangeEndPoint ( text , res ) #NEWLINE# #UNINDENT# return res