writing PrintTree in non-recrusive method