Transform tree with subtree sum mapping | Snowflake Interview Question