nodes: 0, module; 1, function_definition; 2, function_name:add_note; 3, parameters; 4, block; 5, identifier:self; 6, identifier:note; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, if_statement; 13, return_statement; 14, identifier:octave; 15, None; 16, identifier:dynamics; 17, dictionary; 18, comment:"""Add a note to the container and sorts the notes from low to high.
  
          The note can either be a string, in which case you could also use
          the octave and dynamics arguments, or a Note object.
          """; 19, comparison_operator:type(note) == str; 20, block; 21, not_operator; 22, block; 23, comparison_operator:note not in self.notes; 24, block; 25, attribute; 26, call; 27, identifier:str; 28, if_statement; 29, call; 30, raise_statement; 31, identifier:note; 32, attribute; 33, expression_statement; 34, expression_statement; 35, identifier:self; 36, identifier:notes; 37, identifier:type; 38, argument_list; 39, comparison_operator:octave is not None; 40, block; 41, elif_clause; 42, else_clause; 43, identifier:hasattr; 44, argument_list; 45, call; 46, identifier:self; 47, identifier:notes; 48, call; 49, call; 50, identifier:note; 51, identifier:octave; 52, None; 53, expression_statement; 54, comparison_operator:len(self.notes) == 0; 55, block; 56, block; 57, identifier:note; 58, string; 59, identifier:UnexpectedObjectError; 60, argument_list; 61, attribute; 62, argument_list; 63, attribute; 64, argument_list; 65, assignment; 66, call; 67, integer:0; 68, expression_statement; 69, if_statement; 70, string_content:name; 71, binary_operator:"Object '%s' was not expected. "
                      "Expecting a mingus.containers.Note object." % note; 72, attribute; 73, identifier:append; 74, identifier:note; 75, attribute; 76, identifier:sort; 77, identifier:note; 78, call; 79, identifier:len; 80, argument_list; 81, assignment; 82, comparison_operator:Note(note, self.notes[-1].octave) < self.notes[-1]; 83, block; 84, else_clause; 85, concatenated_string; 86, identifier:note; 87, identifier:self; 88, identifier:notes; 89, identifier:self; 90, identifier:notes; 91, identifier:Note; 92, argument_list; 93, attribute; 94, identifier:note; 95, call; 96, call; 97, subscript; 98, expression_statement; 99, block; 100, string:"Object '%s' was not expected. "; 101, string:"Expecting a mingus.containers.Note object."; 102, identifier:note; 103, identifier:octave; 104, identifier:dynamics; 105, identifier:self; 106, identifier:notes; 107, identifier:Note; 108, argument_list; 109, identifier:Note; 110, argument_list; 111, attribute; 112, unary_operator; 113, assignment; 114, expression_statement; 115, identifier:note; 116, integer:4; 117, identifier:dynamics; 118, identifier:note; 119, attribute; 120, identifier:self; 121, identifier:notes; 122, integer:1; 123, identifier:note; 124, call; 125, assignment; 126, subscript; 127, identifier:octave; 128, identifier:Note; 129, argument_list; 130, identifier:note; 131, call; 132, attribute; 133, unary_operator; 134, identifier:note; 135, binary_operator:self.notes[-1].octave + 1; 136, identifier:dynamics; 137, identifier:Note; 138, argument_list; 139, identifier:self; 140, identifier:notes; 141, integer:1; 142, attribute; 143, integer:1; 144, identifier:note; 145, attribute; 146, identifier:dynamics; 147, subscript; 148, identifier:octave; 149, subscript; 150, identifier:octave; 151, attribute; 152, unary_operator; 153, attribute; 154, unary_operator; 155, identifier:self; 156, identifier:notes; 157, integer:1; 158, identifier:self; 159, identifier:notes; 160, integer:1
code: def add_note(self, note, octave=None, dynamics={}):
          """Add a note to the container and sorts the notes from low to high.
  
          The note can either be a string, in which case you could also use
          the octave and dynamics arguments, or a Note object.
          """
          if type(note) == str:
              if octave is not None:
                  note = Note(note, octave, dynamics)
              elif len(self.notes) == 0:
                  note = Note(note, 4, dynamics)
              else:
                  if Note(note, self.notes[-1].octave) < self.notes[-1]:
                      note = Note(note, self.notes[-1].octave + 1, dynamics)
                  else:
                      note = Note(note, self.notes[-1].octave, dynamics)
          if not hasattr(note, 'name'):
              raise UnexpectedObjectError("Object '%s' was not expected. "
                      "Expecting a mingus.containers.Note object." % note)
          if note not in self.notes:
              self.notes.append(note)
              self.notes.sort()
          return self.notes