[BUGFIX] Check if element is present before finding a parent