Instead of looking up the element again, can't the length of 'parent' be checked?