Backport Consider more trees as trivial for inlining.

(cherry picked from commit d1adb57d85f3f0f81ae6d69fb252cd1f43803954)