function findSanta( queue, depth ) {
const seen = new Set();
function santaSearch( queue, depth = 0 ) {
let newQueue = [];
for ( let i = 0; i < queue.length; i++ ) {
const testObj = queue[i];
if ( ! testObj ) continue;
if ( seen.has( testObj ) ) continue;
if ( testObj.orbitedBy.includes( santa ) ) return depth;
seen.add( testObj );
newQueue = [ ...newQueue, ...testObj.orbitedBy, testObj.orbits ];
}
return santaSearch( newQueue, depth + 1 );
}
return santaSearch( queue, depth );
}