'Called by __init__. Do not directly call this method.'

def _get_category_nodes(self, sort):

    self.row_map = []
    self.categories = OrderedDict()
    try:
        data = self.db.new_api.get_categories(sort=sort, book_ids=self.get_book_ids_to_use(), first_letter_sort=(self.collapse_model == u'first    letter'))
    except:
        import traceback
        traceback.print_exc()
        data = self.db.new_api.get_categories(sort=sort, first_letter_sort=(self.collapse_model == u'first    letter'))
        self.restriction_error.emit()
    if self.filter_categories_by:
        for category in data.keys():
            data[category] = [t for t in data[category] if (lower(t.name).find(self.filter_categories_by) >= 0)]
    tb_categories = self.db.field_metadata
    for category in tb_categories:
        if (category in data):
            self.categories[category] = tb_categories[category][u'name']
    try:
        order = tweaks[u'tag_browser_category_order']
        if (not isinstance(order, dict)):
            raise TypeError()
    except:
        print(u'Tweak    tag_browser_category_order    is    not    valid.    Ignored')
        order = {u'*': 100}
    defvalue = order.get(u'*', 100)
    self.row_map = sorted(self.categories, key=(lambda x: order.get(x, defvalue)))
    return data
