Code within else can be moved out of else because if the condition isLastNestedObject is satisfied it will exit this method.