make ComputeTopDownOrdering significantly faster and use less stack space