Updated guard in getAncestors, using _.keys to check size of accumulator.