Improve recursion handling of empty lists