I had to look up slice(0). I wasn't familar with the idiom. How about using slice(0,maxDepth) and adding a comment: // copy array