I don't know the logic, but it seems that root_blog_node.position == the position in the nodes list; visible_roots[root_blog_node.position] may be != nodes[root_blog_node.position].

I guess that nodes[root_blog_node.position] is root_blog_node.

I see that there is an IndexError catch, but in case we don't have an out of bounds situation, there might be subtle bugs there.

Again, I don't know the logic, maybe this is as intended.