I suspect (although I haven't checked the code) that this is actually a "dead code elimination" algorithm which is easier to write than a tree shaking algorithm.
Tree-shaking is actually "live code inclusion", the opposite side of dead code elimination.