def filter(self, *args, **kwargs):
ancestors = set()<EOL>filtrates = set()<EOL>config = type(self)(self.device,  deepcopy(self.ele))<EOL>results = config.xpath(*args, **kwargs)<EOL>if isinstance(results, list):<EOL><INDENT>for node in results:<EOL><INDENT>if etree.iselement(node):<EOL><INDENT>ancestors |= set(list(node.iterancestors()))<EOL>filtrates.add(node)<EOL><DEDENT><DEDENT>if filtrates:<EOL><INDENT>config._node_filter(config.ele, ancestors, filtrates)<EOL><DEDENT>else:<EOL><INDENT>config.ele = etree.Element(config_tag, nsmap={'<STR_LIT>': nc_url})<EOL><DEDENT><DEDENT>return config<EOL>
filter

        High-level api: Filter the config using xpath method. If namespaces is
        not given, self.ns is used by default.

        Returns
        -------

        Config
            A new Config instance which has less content according to your
            filter xpath expression.