def get_schema_node(self, config_node):
def get_child(parent, tag):<EOL><INDENT>children = [i for i in parent.iter(tag=tag)if i.attrib['<STR_LIT:type>'] != '<STR_LIT>' andi.attrib['<STR_LIT:type>'] != '<STR_LIT>' andis_parent(parent, i)]<EOL>if len(children) == <NUM_LIT:1>:<EOL><INDENT>return children[<NUM_LIT:0>]<EOL><DEDENT>elif len(children) > <NUM_LIT:1>:<EOL><INDENT>if parent.getparent() is None:<EOL><INDENT>raise ModelError("<STR_LIT>".format(tag))<EOL><DEDENT>else:<EOL><INDENT>raise ModelError("<STR_LIT>""<STR_LIT>".format(self.get_xpath(parent), tag))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>def is_parent(node1, node2):<EOL><INDENT>ancestors = {id(a): a for a in node2.iterancestors()}<EOL>ids_1 = set([id(a) for a in node1.iterancestors()])<EOL>ids_2 = set([id(a) for a in node2.iterancestors()])<EOL>if not ids_1 < ids_2:<EOL><INDENT>return False<EOL><DEDENT>for i in ids_2 - ids_1:<EOL><INDENT>if ancestors[i] is not node1 andancestors[i].attrib['<STR_LIT:type>'] != '<STR_LIT>' andancestors[i].attrib['<STR_LIT:type>'] != '<STR_LIT>':<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL><DEDENT>n = Composer(self, config_node)<EOL>config_path = n.path<EOL>if '<STR_LIT:U+0020>'.join(config_path) in self.nodes:<EOL><INDENT>return self.nodes['<STR_LIT:U+0020>'.join(config_path)]<EOL><DEDENT>if len(config_path) > <NUM_LIT:1>:<EOL><INDENT>parent = self.get_schema_node(config_node.getparent())<EOL>if parent is None:<EOL><INDENT>return None<EOL><DEDENT>else:<EOL><INDENT>child = get_child(parent, config_node.tag)<EOL>if child is not None:<EOL><INDENT>self.nodes['<STR_LIT:U+0020>'.join(config_path)] = child<EOL><DEDENT>return child<EOL><DEDENT><DEDENT>else:<EOL><INDENT>tree = self.models[n.model_name].tree<EOL>child = get_child(tree, config_node.tag)<EOL>if child is not None:<EOL><INDENT>self.nodes['<STR_LIT:U+0020>'.join(config_path)] = child<EOL><DEDENT>return child<EOL><DEDENT>
get_schema_node

        High-level api: Given an Element node in config, get_schema_node returns
        a schema node (defined in RFC 6020), which is an Element node in the
        schema tree.

        Parameters
        ----------

        config_node : `Element`
            An Element node in config tree.

        Returns
        -------

        Element
            A schema node, or None when nothing can be found.

        Raises
        ------

        ModelError
            If identifier is not unique in a namespace.


        Code Example::

            >>> device.nc.load_model('openconfig-interfaces')
            >>> reply = device.nc.get_config(models='openconfig-interfaces')
            >>> config = device.nc.extract_config(reply)
            >>> print(config)
            ...
            >>> config.ns
            ...
            >>> config_nodes = config.xpath('/nc:config/oc-if:interfaces/oc-if:interface[oc-if:name="GigabitEthernet0/0"]')
            >>> config_node = config_nodes[0]
            >>>
            >>> device.nc.get_schema_node(config_node)
            <Element {http://openconfig.net/yang/interfaces}interface at 0xf11acfcc>
            >>>