You can use 'apt autoremove' to remove transitive dependencies that aren't required anymore. I think you sometimes have to run it multiple times, though, because it won't recognize that a dependency of a transitive dependency is no longer required after removing the first transitive dependency.