def get_field_references(ctx, field_names, simplify=False):
field_dict = {}<EOL>for field_name in field_names:<EOL><INDENT>field = get_field(ctx, field_name)<EOL>if (<EOL>not simplify<EOL>or field is not None<EOL>and (not isinstance(field, list) or len(field) > <NUM_LIT:0>)<EOL>):<EOL><INDENT>if isinstance(field, list):<EOL><INDENT>value = [ctx.children.index(el) for el in field]<EOL><DEDENT>elif field is not None:<EOL><INDENT>value = ctx.children.index(field)<EOL><DEDENT>else:<EOL><INDENT>value = None<EOL><DEDENT>field_dict[field_name] = value<EOL><DEDENT><DEDENT>return field_dict<EOL>
Create a mapping from fields to corresponding child indices
:param ctx: ANTLR node
:param field_names: list of strings
:param simplify: if True, omits fields with empty lists or None
    this makes it easy to detect nodes that only use a single field
    but it requires more work to combine fields that can be empty
:return: mapping str -> int | int[]