This is very clever, well done. The tree parser code looks satisfying to write. I would have had a little cackle to myself the first time it executed properly.
But if I was your boss and reviewing the code I’d throw it out and accept the boring if statement version. This is why: