adding python code for tree demo