#NEWLINE# def __field_to_subfields( self , field ) : #NEWLINE# #INDENT# 'Fully describes data represented by field, including the nested case.\n\n    In the case that the field is not a message field, we have no fields nested\n    within a message definition, so we can simply return that field. However, in\n    the nested case, we can\'t simply describe the data with one field or even\n    with one chain of fields.\n\n    For example, if we have a message field\n\n      m_field = messages.MessageField(RefClass, 1)\n\n    which references a class with two fields:\n\n      class RefClass(messages.Message):\n        one = messages.StringField(1)\n        two = messages.IntegerField(2)\n\n    then we would need to include both one and two to represent all the\n    data contained.\n\n    Calling __field_to_subfields(m_field) would return:\n    [\n      [<MessageField "m_field">, <StringField "one">],\n      [<MessageField "m_field">, <StringField "two">],\n    ]\n\n    If the second field was instead a message field\n\n      class RefClass(messages.Message):\n        one = messages.StringField(1)\n        two = messages.MessageField(OtherRefClass, 2)\n\n    referencing another class with two fields\n\n      class OtherRefClass(messages.Message):\n        three = messages.BooleanField(1)\n        four = messages.FloatField(2)\n\n    then we would need to recurse one level deeper for two.\n\n    With this change, calling __field_to_subfields(m_field) would return:\n    [\n      [<MessageField "m_field">, <StringField "one">],\n      [<MessageField "m_field">, <StringField "two">, <StringField "three">],\n      [<MessageField "m_field">, <StringField "two">, <StringField "four">],\n    ]\n\n    Args:\n      field: An instance of a subclass of messages.Field.\n\n    Returns:\n      A list of lists, where each sublist is a list of fields.\n    ' #NEWLINE# if ( not isinstance ( field , messages . MessageField ) ) : #NEWLINE# #INDENT# return [ [ field ] ] #NEWLINE# #UNINDENT# result = [ ] #NEWLINE# for subfield in sorted ( field . message_type . all_fields ( ) , key = ( lambda f : f . number ) ) : #NEWLINE# #INDENT# subfield_results = self . __field_to_subfields ( subfield ) #NEWLINE# for subfields_list in subfield_results : #NEWLINE# #INDENT# subfields_list . insert ( 0 , field ) #NEWLINE# result . append ( subfields_list ) #NEWLINE# #UNINDENT# #UNINDENT# return result