function getChildren( elem ){
var child = elem.firstChild, res = [];
while ( child ) {
if ( child.nodeType == 1 ) {
res [ res.length ] = child;
}
child = child.nextSibling;
}
return res;
}
var childrenNode = getChildren( node );
var firstChild = childrenNode.length ? childrenNode[0] : null;
var lastChild = childrenNode.length ? childrenNode[res.length - 1] : null;