Find closest matching parent element