Fixing more bugs and added features

Fixed more bugs. The tree depth is not limited. It can grow to infinite
length. Also added a feature to search for a location from the tree.
Rearranged the whole code to directly plug into a web application.