Auto-collapse folder tree for directories not in use

Is it possible to auto-collapse the folder tree for the directories that I am not currently in? I ask because as soon as you navigate to a few directories, all of the expanded tree gets to be quite long, and it just gets longer and longer as you work. It would be nice to have the option to have the directories collapse once you leave them and go to another folder, or tab, or pane.