traverse dom recursively