finished functions/subroutines to bring tree representations from tree to flat and back, wrote test for it