<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_referenced_fields_and_fragment_names( context, # ValidationContext cached_fields_and_fragment_names, # type: Dict[SelectionSet, Tuple[Dict[str, List[Tuple[Union[GraphQLInterfaceType, GraphQLObjectType, None], Field, GraphQLField]]], List[str]]] fragment, # type: InlineFragment ):
 """Given a reference to a fragment, return the represented collection of fields as well as a list of nested fragment names referenced via fragment spreads."""


    # Short-circuit building a type from the AST if possible.
    cached = cached_fields_and_fragment_names.get(fragment.selection_set)

    if cached:
        return cached

    fragment_type = type_from_ast(  # type: ignore
        context.get_schema(), fragment.type_condition
    )

    return _get_fields_and_fragments_names(  # type: ignore
        context, cached_fields_and_fragment_names, fragment_type, fragment.selection_set
    )