Check if function undotree exists before using it

Close #11.