You can do it either way in XPath thanks to how you can use a path expression and/or predicates almost everywhere in a query
# Find all elements li and select the parent element for each
//li/..
# Find all element nodes with a child element named li
//*[li]
# Non-abbreviated queries
/descendant::li/parent::*
/descendant::*[child::li]
# CSS using :has
:has(> li)
Looks like that psuedo-class has not been implemented in the kuchiki library that htmlq uses though.
[0]: https://developer.mozilla.org/en-US/docs/Web/CSS/:has