private Set<Node> check(List<Selector> parts) throws NodeSelectorException {
        Set<Node> result = new LinkedHashSet<Node>();
        result.add(root);
        for (Selector selector : parts) {
            NodeTraversalChecker checker = new TagChecker(selector);
            result = checker.check(result, root);
            if (selector.hasSpecifiers()) {
                for (Specifier specifier : selector.getSpecifiers()) {
                    switch (specifier.getType()) {
                    case ATTRIBUTE:
                        checker = new AttributeSpecifierChecker((AttributeSpecifier) specifier);
                        break;
                    case PSEUDO:
                        if (specifier instanceof PseudoClassSpecifier) {
                            checker = new PseudoClassSpecifierChecker((PseudoClassSpecifier) specifier);
                        } else if (specifier instanceof PseudoNthSpecifier) {
                            checker = new PseudoNthSpecifierChecker((PseudoNthSpecifier) specifier);
                        }
                        
                        break;
                    case NEGATION:
                        final Set<Node> negationNodes = checkNegationSpecifier((NegationSpecifier) specifier);
                        checker = new NodeTraversalChecker() {
                            @Override
                            public Set<Node> check(Set<Node> nodes, Node root) throws NodeSelectorException {
                                Set<Node> set = new LinkedHashSet<Node>(nodes);
                                set.removeAll(negationNodes);
                                return set;
                            }
                        };
                        
                        break;
                    }
                    
                    result = checker.check(result, root);
                    if (result.isEmpty()) {
                        // Bail out early.
                        return result;
                    }
                }
            }
        }
        
        return result;
    }
private Set < Node > check ( List < Selector > parts ) throws NodeSelectorException { Set < Node > result = new LinkedHashSet < Node > ( ) ; result . add ( root ) ; for ( Selector selector : parts ) { NodeTraversalChecker checker = new TagChecker ( selector ) ; result = checker . check ( result , root ) ; if ( selector . hasSpecifiers ( ) ) { for ( Specifier specifier : selector . getSpecifiers ( ) ) { switch ( specifier . getType ( ) ) { case ATTRIBUTE : checker = new AttributeSpecifierChecker ( ( AttributeSpecifier ) specifier ) ; break ; case PSEUDO : if ( specifier instanceof PseudoClassSpecifier ) { checker = new PseudoClassSpecifierChecker ( ( PseudoClassSpecifier ) specifier ) ; } else if ( specifier instanceof PseudoNthSpecifier ) { checker = new PseudoNthSpecifierChecker ( ( PseudoNthSpecifier ) specifier ) ; } break ; case NEGATION : final Set < Node > negationNodes = checkNegationSpecifier ( ( NegationSpecifier ) specifier ) ; checker = new NodeTraversalChecker ( ) { @ Override public Set < Node > check ( Set < Node > nodes , Node root ) throws NodeSelectorException { Set < Node > set = new LinkedHashSet < Node > ( nodes ) ; set . removeAll ( negationNodes ) ; return set ; } } ; break ; } result = checker . check ( result , root ) ; if ( result . isEmpty ( ) ) { return result ; } } } } return result ; }
Check the list of selector <em>parts</em> and return a set of nodes with the result.

@param parts A list of selector <em>parts</em>.
@return A set of nodes.
@throws NodeSelectorException In case of an error.