utility functions: firstChild and documentRepaint