[ngrams] tree edit refactoring

Doesn't work yet as expected, but some progress made in good direction.
2 jobs for 409-dev-ngrams-table-edit-and-search in 0 seconds (queued for 65 minutes and 9 seconds)
Status Job ID Name Coverage
  Test
failed #4122
deps

failed #4123
test

 
Name Stage Failure
failed
test Test There has been a timeout failure or the job got stuck. Check your timeout limits or try again
No job trace
failed
deps Test There has been a timeout failure or the job got stuck. Check your timeout limits or try again
No job trace