DisplayObjectContainer Handling Children with Same Name

Hey all, pretty simple question.


import flash.display.Sprite;

var sp1:Sprite = new Sprite( );
var sp2_1:Sprite = new Sprite( );
var sp2_2:Sprite = new Sprite( );

sp1.name = "sp1";
sp2_1.name = "sp2";
sp2_2.name = "sp2";

sp1.addChild( sp2_1 );
sp1.addChild( sp2_2 );

trace( sp1.getChildByName( "sp2" ) == sp2_1 ); // true
trace( sp1.getChildByName( "sp2" ) == sp2_2 ); // false

I’d assume from this that there is no correcting done for children with the same name being added to the same parent. I ask this question because I’m creating a structure that needs to mimic the display list and I’d like to keep behavior consistent.

Another question: I’d assume internally the children are saved in something similar to a Dictionary object, does anyone know if this is true? And then getChildByName simply does a foreach loop and returns the first match on a name?