Move utility functions to detect DOM instances to the utility module