ziafazal/api-optimize-completions-leader-list: optimized get_course_leaf_nodes

@chrisndodge @mattdrayer optimized `get_course_leaf_nodes` as suggested by Chris in MCKIN-2134.