nodes: 0, module; 1, function_definition; 2, function_name:union; 3, parameters; 4, block; 5, identifier:self; 6, identifier:other; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, if_statement; 12, return_statement; 13, identifier:sort; 14, None; 15, comment:"""
          Form the union of two Index objects and sorts if possible
  
          Parameters
          ----------
          other : Index or array-like
  
          sort : False or None, default None
              Whether to sort resulting index. ``sort=None`` returns a
              mononotically increasing ``RangeIndex`` if possible or a sorted
              ``Int64Index`` if not. ``sort=False`` always returns an
              unsorted ``Int64Index``
  
              .. versionadded:: 0.25.0
  
          Returns
          -------
          union : Index
          """; 16, call; 17, boolean_operator; 18, block; 19, boolean_operator; 20, block; 21, call; 22, attribute; 23, argument_list; 24, boolean_operator; 25, comparison_operator:len(self) == 0; 26, return_statement; 27, call; 28, comparison_operator:sort is None; 29, expression_statement; 30, expression_statement; 31, expression_statement; 32, expression_statement; 33, if_statement; 34, if_statement; 35, if_statement; 36, expression_statement; 37, expression_statement; 38, if_statement; 39, attribute; 40, argument_list; 41, identifier:self; 42, identifier:_assert_can_do_setop; 43, identifier:other; 44, comparison_operator:len(other) == 0; 45, call; 46, call; 47, integer:0; 48, call; 49, identifier:isinstance; 50, argument_list; 51, identifier:sort; 52, None; 53, assignment; 54, assignment; 55, assignment; 56, assignment; 57, comparison_operator:self._step < 0; 58, block; 59, comparison_operator:other._step < 0; 60, block; 61, boolean_operator; 62, block; 63, elif_clause; 64, elif_clause; 65, assignment; 66, assignment; 67, comparison_operator:step_o == step_s; 68, block; 69, elif_clause; 70, elif_clause; 71, attribute; 72, identifier:union; 73, identifier:other; 74, keyword_argument; 75, call; 76, integer:0; 77, attribute; 78, argument_list; 79, identifier:len; 80, argument_list; 81, attribute; 82, argument_list; 83, identifier:other; 84, identifier:RangeIndex; 85, pattern_list; 86, expression_list; 87, identifier:end_s; 88, binary_operator:self._start + self._step * (len(self) - 1); 89, pattern_list; 90, expression_list; 91, identifier:end_o; 92, binary_operator:other._start + other._step * (len(other) - 1); 93, attribute; 94, integer:0; 95, expression_statement; 96, attribute; 97, integer:0; 98, expression_statement; 99, comparison_operator:len(self) == 1; 100, comparison_operator:len(other) == 1; 101, expression_statement; 102, comparison_operator:len(self) == 1; 103, block; 104, comparison_operator:len(other) == 1; 105, block; 106, identifier:start_r; 107, call; 108, identifier:end_r; 109, call; 110, identifier:step_o; 111, identifier:step_s; 112, if_statement; 113, if_statement; 114, comparison_operator:step_o % step_s == 0; 115, block; 116, comparison_operator:step_s % step_o == 0; 117, block; 118, identifier:self; 119, identifier:_int64index; 120, identifier:sort; 121, identifier:sort; 122, identifier:len; 123, argument_list; 124, identifier:self; 125, identifier:equals; 126, identifier:other; 127, identifier:self; 128, call; 129, identifier:union; 130, identifier:other; 131, keyword_argument; 132, identifier:start_s; 133, identifier:step_s; 134, attribute; 135, attribute; 136, attribute; 137, binary_operator:self._step * (len(self) - 1); 138, identifier:start_o; 139, identifier:step_o; 140, attribute; 141, attribute; 142, attribute; 143, binary_operator:other._step * (len(other) - 1); 144, identifier:self; 145, identifier:_step; 146, assignment; 147, identifier:other; 148, identifier:_step; 149, assignment; 150, call; 151, integer:1; 152, call; 153, integer:1; 154, assignment; 155, call; 156, integer:1; 157, expression_statement; 158, call; 159, integer:1; 160, expression_statement; 161, identifier:min; 162, argument_list; 163, identifier:max; 164, argument_list; 165, parenthesized_expression; 166, block; 167, parenthesized_expression; 168, block; 169, binary_operator:step_o % step_s; 170, integer:0; 171, if_statement; 172, binary_operator:step_s % step_o; 173, integer:0; 174, if_statement; 175, identifier:other; 176, identifier:super; 177, argument_list; 178, identifier:sort; 179, identifier:sort; 180, identifier:self; 181, identifier:_start; 182, identifier:self; 183, identifier:_step; 184, identifier:self; 185, identifier:_start; 186, attribute; 187, parenthesized_expression; 188, identifier:other; 189, identifier:_start; 190, identifier:other; 191, identifier:_step; 192, identifier:other; 193, identifier:_start; 194, attribute; 195, parenthesized_expression; 196, pattern_list; 197, expression_list; 198, pattern_list; 199, expression_list; 200, identifier:len; 201, argument_list; 202, identifier:len; 203, argument_list; 204, identifier:step_s; 205, assignment; 206, identifier:len; 207, argument_list; 208, assignment; 209, identifier:len; 210, argument_list; 211, assignment; 212, identifier:start_s; 213, identifier:start_o; 214, identifier:end_s; 215, identifier:end_o; 216, boolean_operator; 217, return_statement; 218, boolean_operator; 219, return_statement; 220, identifier:step_o; 221, identifier:step_s; 222, parenthesized_expression; 223, block; 224, identifier:step_s; 225, identifier:step_o; 226, parenthesized_expression; 227, block; 228, identifier:self; 229, identifier:_step; 230, binary_operator:len(self) - 1; 231, identifier:other; 232, identifier:_step; 233, binary_operator:len(other) - 1; 234, identifier:start_s; 235, identifier:step_s; 236, identifier:end_s; 237, identifier:end_s; 238, unary_operator; 239, identifier:start_s; 240, identifier:start_o; 241, identifier:step_o; 242, identifier:end_o; 243, identifier:end_o; 244, unary_operator; 245, identifier:start_o; 246, identifier:self; 247, identifier:other; 248, identifier:step_o; 249, call; 250, identifier:self; 251, identifier:step_s; 252, identifier:step_o; 253, identifier:other; 254, identifier:step_o; 255, identifier:step_s; 256, boolean_operator; 257, comparison_operator:(start_o - end_s) <= step_s; 258, call; 259, boolean_operator; 260, parenthesized_expression; 261, call; 262, boolean_operator; 263, return_statement; 264, boolean_operator; 265, return_statement; 266, call; 267, integer:1; 268, call; 269, integer:1; 270, identifier:step_s; 271, identifier:step_o; 272, identifier:abs; 273, argument_list; 274, comparison_operator:(start_s - start_o) % step_s == 0; 275, comparison_operator:(start_s - end_o) <= step_s; 276, parenthesized_expression; 277, identifier:step_s; 278, identifier:RangeIndex; 279, argument_list; 280, parenthesized_expression; 281, parenthesized_expression; 282, comparison_operator:abs(end_s - end_o) <= step_s / 2; 283, identifier:RangeIndex; 284, argument_list; 285, boolean_operator; 286, parenthesized_expression; 287, call; 288, boolean_operator; 289, parenthesized_expression; 290, call; 291, identifier:len; 292, argument_list; 293, identifier:len; 294, argument_list; 295, binary_operator:self._start - other._start; 296, binary_operator:(start_s - start_o) % step_s; 297, integer:0; 298, parenthesized_expression; 299, identifier:step_s; 300, binary_operator:start_o - end_s; 301, identifier:start_r; 302, binary_operator:end_r + step_s; 303, identifier:step_s; 304, comparison_operator:step_s % 2 == 0; 305, comparison_operator:abs(start_s - start_o) <= step_s / 2; 306, call; 307, binary_operator:step_s / 2; 308, identifier:start_r; 309, binary_operator:end_r + step_s / 2; 310, binary_operator:step_s / 2; 311, comparison_operator:(start_o - start_s) % step_s == 0; 312, parenthesized_expression; 313, comparison_operator:end_o - step_s <= end_s; 314, identifier:RangeIndex; 315, argument_list; 316, comparison_operator:(start_s - start_o) % step_o == 0; 317, parenthesized_expression; 318, comparison_operator:end_s - step_o <= end_o; 319, identifier:RangeIndex; 320, argument_list; 321, identifier:self; 322, identifier:other; 323, attribute; 324, attribute; 325, parenthesized_expression; 326, identifier:step_s; 327, binary_operator:start_s - end_o; 328, identifier:start_o; 329, identifier:end_s; 330, identifier:end_r; 331, identifier:step_s; 332, binary_operator:step_s % 2; 333, integer:0; 334, call; 335, binary_operator:step_s / 2; 336, identifier:abs; 337, argument_list; 338, identifier:step_s; 339, integer:2; 340, identifier:end_r; 341, binary_operator:step_s / 2; 342, identifier:step_s; 343, integer:2; 344, binary_operator:(start_o - start_s) % step_s; 345, integer:0; 346, comparison_operator:start_o + step_s >= start_s; 347, binary_operator:end_o - step_s; 348, identifier:end_s; 349, identifier:start_r; 350, binary_operator:end_r + step_s; 351, identifier:step_s; 352, binary_operator:(start_s - start_o) % step_o; 353, integer:0; 354, comparison_operator:start_s + step_o >= start_o; 355, binary_operator:end_s - step_o; 356, identifier:end_o; 357, identifier:start_r; 358, binary_operator:end_r + step_o; 359, identifier:step_o; 360, identifier:self; 361, identifier:_start; 362, identifier:other; 363, identifier:_start; 364, binary_operator:start_s - start_o; 365, identifier:start_s; 366, identifier:end_o; 367, identifier:step_s; 368, integer:2; 369, identifier:abs; 370, argument_list; 371, identifier:step_s; 372, integer:2; 373, binary_operator:end_s - end_o; 374, identifier:step_s; 375, integer:2; 376, parenthesized_expression; 377, identifier:step_s; 378, binary_operator:start_o + step_s; 379, identifier:start_s; 380, identifier:end_o; 381, identifier:step_s; 382, identifier:end_r; 383, identifier:step_s; 384, parenthesized_expression; 385, identifier:step_o; 386, binary_operator:start_s + step_o; 387, identifier:start_o; 388, identifier:end_s; 389, identifier:step_o; 390, identifier:end_r; 391, identifier:step_o; 392, identifier:start_s; 393, identifier:start_o; 394, binary_operator:start_s - start_o; 395, identifier:end_s; 396, identifier:end_o; 397, binary_operator:start_o - start_s; 398, identifier:start_o; 399, identifier:step_s; 400, binary_operator:start_s - start_o; 401, identifier:start_s; 402, identifier:step_o; 403, identifier:start_s; 404, identifier:start_o; 405, identifier:start_o; 406, identifier:start_s; 407, identifier:start_s; 408, identifier:start_o
code: def union(self, other, sort=None):
          """
          Form the union of two Index objects and sorts if possible
  
          Parameters
          ----------
          other : Index or array-like
  
          sort : False or None, default None
              Whether to sort resulting index. ``sort=None`` returns a
              mononotically increasing ``RangeIndex`` if possible or a sorted
              ``Int64Index`` if not. ``sort=False`` always returns an
              unsorted ``Int64Index``
  
              .. versionadded:: 0.25.0
  
          Returns
          -------
          union : Index
          """
          self._assert_can_do_setop(other)
          if len(other) == 0 or self.equals(other) or len(self) == 0:
              return super().union(other, sort=sort)
  
          if isinstance(other, RangeIndex) and sort is None:
              start_s, step_s = self._start, self._step
              end_s = self._start + self._step * (len(self) - 1)
              start_o, step_o = other._start, other._step
              end_o = other._start + other._step * (len(other) - 1)
              if self._step < 0:
                  start_s, step_s, end_s = end_s, -step_s, start_s
              if other._step < 0:
                  start_o, step_o, end_o = end_o, -step_o, start_o
              if len(self) == 1 and len(other) == 1:
                  step_s = step_o = abs(self._start - other._start)
              elif len(self) == 1:
                  step_s = step_o
              elif len(other) == 1:
                  step_o = step_s
              start_r = min(start_s, start_o)
              end_r = max(end_s, end_o)
              if step_o == step_s:
                  if ((start_s - start_o) % step_s == 0 and
                          (start_s - end_o) <= step_s and
                          (start_o - end_s) <= step_s):
                      return RangeIndex(start_r, end_r + step_s, step_s)
                  if ((step_s % 2 == 0) and
                          (abs(start_s - start_o) <= step_s / 2) and
                          (abs(end_s - end_o) <= step_s / 2)):
                      return RangeIndex(start_r, end_r + step_s / 2, step_s / 2)
              elif step_o % step_s == 0:
                  if ((start_o - start_s) % step_s == 0 and
                          (start_o + step_s >= start_s) and
                          (end_o - step_s <= end_s)):
                      return RangeIndex(start_r, end_r + step_s, step_s)
              elif step_s % step_o == 0:
                  if ((start_s - start_o) % step_o == 0 and
                          (start_s + step_o >= start_o) and
                          (end_s - step_o <= end_o)):
                      return RangeIndex(start_r, end_r + step_o, step_o)
  
          return self._int64index.union(other, sort=sort)