I have found that this seems to primarily be occurring when switching from the Debug navigator to the Project navigator. If I switch to any of the other navigators (e.g. Issue navigator) and then go back to the Project navigator, then my previous file hierarchy expand/collapse state is recovered.