I think this function should actually be part of Element or Element Factory, not here.