Add an util function to transform binary tree in a better query json form