Previously, the batch insert sorting algorithm worked on a single parent-child level.
Now, it defines a dependency graph which allows us to track if a grandchild belongs to a given grandparent.