cleaned up generateAnagramTree method