def _collect_fields(field_parts_list, include_parents):
fields = []<EOL>subpart_lists = defaultdict(list)<EOL>for parts in field_parts_list:<EOL><INDENT>field, subparts = parts[<NUM_LIT:0>], parts[<NUM_LIT:1>:]<EOL>if subparts:<EOL><INDENT>if include_parents and field not in fields:<EOL><INDENT>fields.append(field)<EOL><DEDENT>subpart_lists[field].append(subparts)<EOL><DEDENT>else:<EOL><INDENT>fields.append(field)<EOL><DEDENT><DEDENT>subfields = dict((field, _collect_fields(subparts, include_parents))<EOL>for field, subparts in six.iteritems(subpart_lists))<EOL>return ParsedFieldList(fields, subfields)<EOL>
utility function to enable recursion in _parse_field_list()