if this is to detect loops and stop when that occurs wouldn't it be better to detect those explicitly or set the limit to number of projects ?