Here’s a simple script for a long chain of parented objects.
Create a bunch of cubes in one place, select then all in the viewport, and run this script. Marquee select them all again, and transform the objects to see the effect. This takes advantage of inherited transformation.
string $null[] = `ls -tr -sl`;
int $n = size($null);
for($i = 0; $i < $n; $i++){
if($i != $n-1){
parent $null[$i] $null[$i+1];
}
}