def gather_parents(tree, elem, key='tokenized_inputs', include_root=True):
    """
    Returns a list of attributes represented by key of all parents,
    of elem.
    """
    lis=[]
    if 'parent_id' in elem:
        parent_id = elem['parent_id']
        while parent_id != tree['id']:
            elem = tree['comments'][parent_id]
            parent_id = elem['parent_id']
            lis.append(elem[key])
        return ([tree[key]] if include_root else []) +lis
    return lis