add tree implementation
add exceptions
add tests and a fix
add serialization