nodes: 0, module; 1, function_definition; 2, function_name:sort_children; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, for_statement; 13, return_statement; 14, identifier:attribute; 15, None; 16, identifier:reverse_order; 17, False; 18, comment:"""
          Sorts the children using either the given attribute or the Node name.
  
          :param attribute: Attribute name used for sorting.
          :type attribute: unicode
          :param reverse_order: Sort in reverse order.
          :type reverse_order: bool
          :return: Method success.
          :rtype: bool
          """; 19, assignment; 20, identifier:attribute; 21, block; 22, else_clause; 23, assignment; 24, identifier:child; 25, attribute; 26, block; 27, True; 28, identifier:sorted_children; 29, list; 30, expression_statement; 31, expression_statement; 32, for_statement; 33, expression_statement; 34, expression_statement; 35, block; 36, attribute; 37, identifier:sorted_children; 38, identifier:self; 39, identifier:__children; 40, expression_statement; 41, assignment; 42, assignment; 43, identifier:child; 44, attribute; 45, block; 46, assignment; 47, call; 48, expression_statement; 49, identifier:self; 50, identifier:__children; 51, call; 52, identifier:sortable_children; 53, list; 54, identifier:unsortable_children; 55, list; 56, identifier:self; 57, identifier:__children; 58, if_statement; 59, identifier:sorted_children; 60, call; 61, attribute; 62, argument_list; 63, assignment; 64, attribute; 65, argument_list; 66, call; 67, block; 68, else_clause; 69, identifier:sorted; 70, argument_list; 71, identifier:sorted_children; 72, identifier:extend; 73, identifier:unsortable_children; 74, identifier:sorted_children; 75, call; 76, identifier:child; 77, identifier:sort_children; 78, identifier:attribute; 79, identifier:reverse_order; 80, attribute; 81, argument_list; 82, expression_statement; 83, block; 84, identifier:sortable_children; 85, keyword_argument; 86, keyword_argument; 87, identifier:sorted; 88, argument_list; 89, identifier:child; 90, identifier:attribute_exists; 91, identifier:attribute; 92, call; 93, expression_statement; 94, identifier:key; 95, lambda; 96, identifier:reverse; 97, boolean_operator; 98, attribute; 99, keyword_argument; 100, keyword_argument; 101, attribute; 102, argument_list; 103, call; 104, lambda_parameters; 105, attribute; 106, identifier:reverse_order; 107, False; 108, identifier:self; 109, identifier:children; 110, identifier:key; 111, lambda; 112, identifier:reverse; 113, boolean_operator; 114, identifier:sortable_children; 115, identifier:append; 116, identifier:child; 117, attribute; 118, argument_list; 119, identifier:x; 120, call; 121, identifier:value; 122, lambda_parameters; 123, parenthesized_expression; 124, identifier:reverse_order; 125, False; 126, identifier:unsortable_children; 127, identifier:append; 128, identifier:child; 129, identifier:getattr; 130, argument_list; 131, identifier:x; 132, attribute; 133, identifier:x; 134, identifier:attribute; 135, identifier:x; 136, identifier:name
code: def sort_children(self, attribute=None, reverse_order=False):
          """
          Sorts the children using either the given attribute or the Node name.
  
          :param attribute: Attribute name used for sorting.
          :type attribute: unicode
          :param reverse_order: Sort in reverse order.
          :type reverse_order: bool
          :return: Method success.
          :rtype: bool
          """
  
          sorted_children = []
          if attribute:
              sortable_children = []
              unsortable_children = []
              for child in self.__children:
                  if child.attribute_exists(attribute):
                      sortable_children.append(child)
                  else:
                      unsortable_children.append(child)
              sorted_children = sorted(sortable_children, key=lambda x: getattr(
                  x, attribute).value, reverse=reverse_order or False)
              sorted_children.extend(unsortable_children)
          else:
              sorted_children = sorted(self.children, key=lambda x: (x.name), reverse=reverse_order or False)
  
          self.__children = sorted_children
  
          for child in self.__children:
              child.sort_children(attribute, reverse_order)
  
          return True