The CheckboxTreeElement calls many functions in the term_tree_reference.module file. It could be better to have these functions as static public functions within the class. This would allow people to extend CheckboxTreeElement if they need to add their own implementation, and would allow use of these functions but with the ability to override and extend easily if needed.
Move all functions to public static functions within CheckboxTreeElement. Also move the flatten function called by TermReferenceTree into a public static function in TermReferenceTree.
Add a protected static function that just adds query tags to the query done by getChildren. This allows us to override the addQueryTags method to add our own query tags on a custom implementation of this.
Needs review
2.0
Code