def getTreeBuilder(treeType, implementation=None, **kwargs):
treeType = treeType.lower()<EOL>if treeType not in treeBuilderCache:<EOL><INDENT>if treeType == "<STR_LIT>":<EOL><INDENT>from . import dom<EOL>if implementation is None:<EOL><INDENT>from xml.dom import minidom<EOL>implementation = minidom<EOL><DEDENT>return dom.getDomModule(implementation, **kwargs).TreeBuilder<EOL><DEDENT>elif treeType == "<STR_LIT>":<EOL><INDENT>from . import etree_lxml<EOL>treeBuilderCache[treeType] = etree_lxml.TreeBuilder<EOL><DEDENT>elif treeType == "<STR_LIT>":<EOL><INDENT>from . import etree<EOL>if implementation is None:<EOL><INDENT>implementation = default_etree<EOL><DEDENT>return etree.getETreeModule(implementation, **kwargs).TreeBuilder<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("""<STR_LIT>""" % treeType)<EOL><DEDENT><DEDENT>return treeBuilderCache.get(treeType)<EOL>
Get a TreeBuilder class for various types of trees with built-in support

    :arg treeType: the name of the tree type required (case-insensitive). Supported
        values are:

        * "dom" - A generic builder for DOM implementations, defaulting to a
          xml.dom.minidom based implementation.
        * "etree" - A generic builder for tree implementations exposing an
          ElementTree-like interface, defaulting to xml.etree.cElementTree if
          available and xml.etree.ElementTree if not.
        * "lxml" - A etree-based builder for lxml.etree, handling limitations
          of lxml's implementation.

    :arg implementation: (Currently applies to the "etree" and "dom" tree
        types). A module implementing the tree type e.g. xml.etree.ElementTree
        or xml.etree.cElementTree.

    :arg kwargs: Any additional options to pass to the TreeBuilder when
        creating it.

    Example:

    >>> from html5lib.treebuilders import getTreeBuilder
    >>> builder = getTreeBuilder('etree')