[SQL] Support transforming TreeNodes with Option children.

Thanks goes to @marmbrus for his implementation.