if there are hundreds of nodes this loop may leave the UI unresponsive