Using tree stack