def is_tree_uptodate(cursor, tree_json, article_id, revision_id):
    """ function returns true if tree stored in tree_json
    was previous revision of an article with article_id and revision_id
    """
    if tree_json == None:
        return False
    last_inserted_rev_id = TriesA5.get_last_revision_id(tree_json)
    # getting id of previous revision
    rev_parent_id = get_previous_revision_id(cursor, revision_id)
    return rev_parent_id == last_inserted_rev_id
def fetch_new_revisions(cursor, tree_json, article_id):
    """ function returns a list of id's of all revisions
    which have not been added to the tree
    """
    if tree_json == None:
        last_inserted_rev_id = 0
    else:
        last_inserted_rev_id = TriesA5.get_last_revision_id(tree_json)
    latest_revision_id = get_latest_revision_id(cursor, article_id)
    # starting from the latest revision iterate down
    # untill we get whether last inserted revision id or revision with id zero
    all_rev_id = []
    current_rev_id = latest_revision_id
    while True:
        if current_rev_id == 0 or current_rev_id == last_inserted_rev_id:
            break
        all_rev_id.append(current_rev_id)
        current_rev_id = get_previous_revision_id(cursor, current_rev_id)
    return all_rev_id