Fix the .toplevel() code

Broken by: c03595461d687f943b08ce51a215b8ee608a6006