public function filter($node, $tagname)
    {
        $userDefFunction = $this->_userDefFunction;
        $nodes = $userDefFunction($node, $tagname);

        if (!is_array($nodes)) {
            throw new CssParserException(
                "The user defined combinator is not an array"
            );
        }

        // excludes the items that are not elements
        $items = array();
        foreach ($nodes as $node) {
            if ($node instanceof DOMElement) {
                array_push($items, $node);
            }
        }

        return $items;
    }