fixed bugs in tree
added swap method in tree