check if page have children, but not attachment

I am trying to display a sub-menu with the sub-pages of a parent, if you are on the parent page, and the siblings if you are on one of the child pages, but the problem is that if the page have a featured image is recognized az a parent. this is the code I use:

the problem is that I do not get to the second else-if, if the child page have an atachment.