Fix check for existence of parent

When deleting, it's OK to delete entries that are parents of other
entries, as long as all the children will be deleted as well.
Also wrap the original where clause in parentheses to avoid problems
when appending more conditions.

Bug: 31685929
Change-Id: I488c6c732ed1bf252de6160b02900d131731c28f
1 file changed