Looks like this above block is altering 'fullScope' to extract an array of scopes, correct?
Unless I've missed something, it should not be manipulating the input parameter like this..
You could either use a copy, or probably better just to extract between positions. Probably worth validating whilst traversing that is indeed well formed too.