DF_LabelNode *aLabel = NULL, *aPrevious = NULL, *aNext = NULL;
if(!_node->_firstChild && !isCreate) return DF_Label();
- if(_node->_lastChild && _node->_lastChild->_tag < theTag) { //Incremental addition of children
- aPrevious = _node->_lastChild;
+ if(_node->_firstChild && _node->_firstChild->_tag == theTag)
+ return DF_Label(_node->_firstChild);
+
+ if(_node->_lastChild) {
+ if( _node->_lastChild->_tag == theTag) {
+ return DF_Label(_node->_lastChild);
+ }
+ else if( _node->_lastChild->_tag < theTag) { //Incremental addition of children
+ aPrevious = _node->_lastChild;
+ }
}
else {
aLabel = _node->_firstChild;
}
if(!_node->_firstChild || (aNext && aNext == _node->_firstChild) ) _node->_firstChild = aChild;
- if(!aNext) _node->_lastChild = aChild;
+ if(!aNext) {
+ _node->_lastChild = aChild;
+ }
return aChild;
}