Fix get ancestor of entity. closes #2708