Applies changes from 3224816-expand-all-3.x to the 2.x branch.
Closes #3224816 '"Expand all items" ignores Active Trail when starting 2+' for the 2.x branch.