add ancestry index to nodes