unwrap the recursion when removing orphan references. this caused a stack overflow exception if a thew thousand references where empty