implement proper DOM hierarchy detection