[WriteOnly] internal NativeHashMap <int, bool> VisitedIndices; // true if part of the input, false if child

            public void Execute()
            {
                var openIndices = new NativeList <int>(0, Allocator.Temp);

                for (int i = 0; i < VisitedInstanceIds.Length; i++)
                {
                    if (Hierarchy.TryGetIndexForInstanceId(VisitedInstanceIds[i], out int idx))
                    {
                        openIndices.Add(idx);
                        VisitedIndices.TryAdd(idx, true);
                    }
                }

                while (openIndices.Length > 0)
                {
                    int idx = openIndices[openIndices.Length - 1];
                    openIndices.Length--;
                    if (VisitedIndices.TryAdd(idx, false))
                    {
                        VisitedInstanceIds.Add(Hierarchy.GetInstanceIdForIndex(idx));
                    }
                    var iter = Hierarchy.GetChildIndicesForIndex(idx);
                    while (iter.MoveNext())
                    {
                        openIndices.Add(iter.Current);
                    }
                }
            }
        static void CollectHierarchyInstanceIdsImpl(SceneHierarchy hierarchy, NativeArray <int> rootInstanceIds, NativeHashSet <int> visitedInstanceIds)
        {
            var openIndices = new NativeList <int>(0, Allocator.Temp);

            for (int i = 0; i < rootInstanceIds.Length; i++)
            {
                if (hierarchy.TryGetIndexForInstanceId(rootInstanceIds[i], out int idx))
                {
                    openIndices.Add(idx);
                }
            }

            while (openIndices.Length > 0)
            {
                int idx = openIndices[openIndices.Length - 1];
                openIndices.Length--;
                visitedInstanceIds.Add(hierarchy.GetInstanceIdForIndex(idx));
                var iter = hierarchy.GetChildIndicesForIndex(idx);
                while (iter.MoveNext())
                {
                    openIndices.Add(iter.Current);
                }
            }
        }