def METHOD_NAME(
        plan: dict[str, Any]) -> tuple[list[str], list[str], list[str]]:
    '''
    Given a Postgres Query Plan object (parsed from the output of an EXPLAIN
    query), returns a tuple with three items:
    * A list of tables involved
    * A list of remaining queries to parse
    * A list of function names involved
    '''
    table_names: list[str] = []
    queries: list[str] = []
    functions: list[str] = []
    if plan.get('Relation Name'):
        table_names.append(plan['Relation Name'])
    if 'Function Name' in plan:
        if plan['Function Name'].startswith(
                'crosstab'):
            try:
                queries.append(_get_subquery_from_crosstab_call(
                    plan['Function Call']))
            except ValueError:
                table_names.append('_unknown_crosstab_sql')
        else:
            functions.append(plan['Function Name'])
    if 'Plans' in plan:
        for child_plan in plan['Plans']:
            t, q, f = METHOD_NAME(child_plan)
            table_names.extend(t)
            queries.extend(q)
            functions.extend(f)
    return table_names, queries, functions