human
I wrote the below code

    def parse_identifier(item):
        name = item.get_real_name()
        schema_name = item.get_parent_name()
        alias = item.get_alias()
        if (not name):
            schema_name = None
            name = item.get_name()
            alias = (alias or name)
        schema_quoted = (schema_name and (item.value[0] == '"'))
        if (schema_name and (not schema_quoted)):
            schema_name = schema_name.lower()
        quote_count = item.value.count('"')
        name_quoted = ((quote_count > 2) or (quote_count and (not schema_quoted)))
        alias_quoted = (alias and (item.value[(-1)] == '"'))
        if (alias_quoted or (name_quoted and (not alias) and name.islower())):
            alias = (('"' + (alias or name)) + '"')
        if (name and (not name_quoted) and (not name.islower())):
            if (not alias):
                alias = name
            name = name.lower()
        return (schema_name, name, alias)
    for item in token_stream:
        if isinstance(item, IdentifierList):
            for identifier in item.get_identifiers():
                try:
                    schema_name = identifier.get_parent_name()
                    real_name = identifier.get_real_name()
                    is_function = (allow_functions and _identifier_is_function(identifier))
                except AttributeError:
                    continue
                if real_name:
                    (yield TableReference(schema_name, real_name, identifier.get_alias(), is_function))
        elif isinstance(item, Identifier):
            (schema_name, real_name, alias) = parse_identifier(item)
            is_function = (allow_functions and _identifier_is_function(item))
            (yield TableReference(schema_name, real_name, alias, is_function))
        elif isinstance(item, Function):
            (schema_name, real_name, alias) = parse_identifier(item)
            (yield TableReference(None, real_name, alias, allow_functions))

What's a good function header?
 ... Here's a good function header?
assistant
#Here's a good function header.

def extract_table_identifiers(token_stream, allow_functions=True):