Issue #2316739 by eshta: remove unwanted parent elements from selector generation.