[REFACTOR] Move smi tree code into a separate file.