Fixed solution to TREE to run in O(1) instead of O(scary). Algorithm now only works for forests, as intended.