public static Stream < Element > ancestors ( final Element element ) { final Stream . Builder < Element > builder = Stream . builder ( ) ; for ( Node current = element . getParentNode ( ) ; current != null ; current = current . getParentNode ( ) ) { if ( current . getNodeType ( ) == Node . ELEMENT_NODE ) { builder . accept ( ( Element ) current ) ; } } return builder . build ( ) ; }
Stream of element ancestor elements .