private Element searchForKey ( final Element root , final String keyValue ) { if ( root == null || keyValue == null ) { return null ; } final LinkedList < Element > queue = new LinkedList <> ( ) ; queue . add ( root ) ; while ( ! queue . isEmpty ( ) ) { final Element node = queue . removeFirst ( ) ; final NodeList children = node . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { if ( children . item ( i ) . getNodeType ( ) == Node . ELEMENT_NODE ) { queue . add ( ( Element ) children . item ( i ) ) ; } } if ( SUBJECTSCHEME_SUBJECTDEF . matches ( node ) ) { final String key = node . getAttribute ( ATTRIBUTE_NAME_KEYS ) ; if ( keyValue . equals ( key ) ) { return node ; } } } return null ; }
Search subject scheme elements for a given key