fix for sure issue #745 and do not rely on the order of ancestors returned by MongoDB