Thanks for your patience, @amin. I've been under the weather. Often the fastest way to troubleshoot errors like this is to search
this forum for the error message. I found a bunch of results, including this one, by searching "IndexError: pop from empty list".
Give that post a read - I suspect you'll need to fix your taxonomy, but that should steer you in the right direction.