Component for cross-browser tree traversal (adapted from jQuery)