export function traverseTree(dimension, block, depth) {
    let queue = [
        block.north(),
        block.south(),
        block.east(),
        block.west(),
        block.above(),
        block.below()
    ];
    let visited = new Set([block]);
    let currentDepth = 0;
    while (queue.length > 0 && currentDepth < depth) {
        let currentLocation = queue.shift();
        let currentBlock = dimension.getBlock(currentLocation);
        if (currentBlock.typeId.includes('log') &&
            !visited.has(currentLocation)) {
            dimension.runCommand(`setblock ${currentBlock.x} ${currentBlock.y} ${currentBlock.z} air destroy`);
            visited.add(currentLocation);
            currentDepth++;
            let neighbours = [
                currentBlock.north(),
                currentBlock.south(),
                currentBlock.east(),
                currentBlock.west(),
                currentBlock.above(),
                currentBlock.below()
            ];
            for (let neighbour of neighbours)
                queue.push(neighbour);
        }
    }
}
