Fixed some tree functions.
Add test python file.