Is this safe ? If your indexing a tree and that tree happens to be its own root.

What if the root is used in multiple locations ?