Optimize parent/child queries and filters if possible

This is for #3190.  The main optimization is in has_child queries and filters by short-circuiting the parent processing once all known parents have been.  Other small updates to has_child query/filter to not execute the internal children filter when we know there are going to be no hits (no parents found).