<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_stats_table(html_page, div, footer=False):
 """ Returns a generator of all rows in a requested table. When given a PyQuery HTML object and a requested div, this function creates a generator where every item is a PyQuery object pertaining to every row in the table. Generally, each row will contain multiple stats for a given player or team. Parameters html_page : PyQuery object A PyQuery object which contains the requested HTML page contents. div : string The requested tag type and id string in the format "<tag>#<id name>" which aligns to the desired table in the passed HTML page. For example, "div#all_stats_table" or "table#conference_standings". footer : boolean (optional) Optionally return the table footer rows instead of the table header. Returns ------- generator A generator of all row items in a given table. """

    stats_html = html_page(div)
    try:
        stats_table = pq(_remove_html_comment_tags(stats_html))
    except (ParserError, XMLSyntaxError):
        return None
    if footer:
        teams_list = stats_table('tfoot tr').items()
    else:
        teams_list = stats_table('tbody tr').items()
    return teams_list