Move RecursiveIterator implementation to a trait

This enables developers to create their own `Role` entity more easily using this trait without extending `HierarchicalRole`.