Update schedule.cc

Updated my algorithm in nextProcess() to be more defensive by checking else if (root) exists