Save a bunch of totally redundant db queries, and speed things up.
Order the query for the nodes by pid/gid, then save the info from the last node. If the node I'm doing has the same pid/gid as the last one, reuse the info without grabbing it from the database again and recalculating everything. Now it will do one db query for each pid/gid that has an expt swapped in, instead of once per node in use. That cuts the number of db queries by a factor of (avg. # of nodes in use per proj), which is often greater than 10.