Dynatrace Interview Question

a small algorithm task traversing DOM tree