RSTP: factored out some code