#NEWLINE# def insert_error( self , path , node ) : #NEWLINE# #INDENT# ' Adds an error or sub-tree to :attr:tree.\n\n        :param path: Path to the error.\n        :type path: Tuple of strings and integers.\n        :param node: An error message or a sub-tree.\n        :type node: String or dictionary.\n        ' #NEWLINE# if ( len ( path ) == 1 ) : #NEWLINE# #INDENT# field = path [ 0 ] #NEWLINE# if ( field in self . tree ) : #NEWLINE# #INDENT# if isinstance ( self . tree [ field ] , list ) : #NEWLINE# #INDENT# self . tree [ field ] . append ( node ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . tree [ field ] = [ self . tree [ field ] , node ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . tree [ field ] = node #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( path ) >= 1 ) : #NEWLINE# #INDENT# if ( path [ 0 ] in self . tree ) : #NEWLINE# #INDENT# new = self . __class__ ( tree = copy ( self . tree [ path [ 0 ] ] ) ) #NEWLINE# new . insert_error ( path [ 1 : ] , node ) #NEWLINE# self . tree [ path [ 0 ] ] . update ( new . tree ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# child_handler = self . __class__ ( ) #NEWLINE# child_handler . insert_error ( path [ 1 : ] , node ) #NEWLINE# self . tree [ path [ 0 ] ] = child_handler . tree