fixed foldTree and maybe implemented nextLevel