refactors codes and fixes codePro warnings
adds hashmap to remember tree expansion
restores tree to the previous expanded/closed states