convert query plan to tree for UI drawing