ENH: get_prerequisites optimization