tree_editor: When INCLUDE_ANCESTORS is active, preprocess clause list to filter out duplicates, so we won't end up with overly large (and mostly pointless) sql queries.