protected void selectAndAdd ( final Node node , final CssSelector cssSelector , final List < Node > result ) { // ignore all nodes that are not elements if ( node . getNodeType ( ) != Node . NodeType . ELEMENT ) { return ; } boolean matched = cssSelector . accept ( node ) ; if ( matched ) { // check for duplicates if ( result . contains ( node ) ) { return ; } // no duplicate found, add it to the results result . add ( node ) ; } }
Selects single node for single selector and appends it to the results .