Remove package and installed dependencies with apt-get

APT doesn’t manage package changes as transactions, so there’s no built-in operation to undo a package installation (or any other package manipulation). However, it does log all the operations it performs, grouped by end-user request: if you look in /var/log/apt/history.log, you’ll find the mypackage installation, along with a list of all the other packages which were installed automatically alongside it. You can use this to undo the installation manually.

You could also use aptitude instead, for your general package management: it effectively autoremoves by default. This won’t help you right now though since it will want to remove the same 166MiB of packages as apt autoremove.

As pointed out by Weijun Zhou, yum and dnf do manage package changes as units which can be undone (in some circumstances). dnf history will list the transactions stored in the history, and dnf history rollback or dnf history undo can be used to roll the history back or undo a specific transaction (if possible). I’m not sure yum or dnf can be used properly instead of APT on Debian-based systems; you might need to switch to Fedora, RHEL or CentOS if you want to use those tools for all your package management.