Turn the Python prototypes for tree exploration into production code, integrate to SAGE.

Summary
Turn the Python prototypes for tree exploration into production code, integrate to SAGE.