Fix for has_child can cause an infinite loop (100% CPU) when used in bool query

https://github.com/elasticsearch/elasticsearch/issues/3955