#NEWLINE# def AddPath( self , path ) : #NEWLINE# #INDENT# "Adds a field path into the tree.\n\n    If the field path to add is a sub-path of an existing field path\n    in the tree (i.e., a leaf node), it means the tree already matches\n    the given path so nothing will be added to the tree. If the path\n    matches an existing non-leaf node in the tree, that non-leaf node\n    will be turned into a leaf node with all its children removed because\n    the path matches all the node's children. Otherwise, a new path will\n    be added.\n\n    Args:\n      path: The field path to add.\n    " #NEWLINE# node = self . _root #NEWLINE# for name in path . split ( '.' ) : #NEWLINE# #INDENT# if ( name not in node ) : #NEWLINE# #INDENT# node [ name ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not node [ name ] ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# node = node [ name ] #NEWLINE# #UNINDENT# node . clear ( )