fn root(parents: &mut [usize], index: usize) -> usize
Finds a dependency group’s representative while shortening the parent chain.