Rewrite the is_run_as_leaf method to also work for top assistant; test it