count based on parent selector if it exists