GF_Err gf_node_register(GF_Node *node, GF_Node *parentNode)
{
	if (!node) return GF_OK;

	node->sgprivate->num_instances ++;
	/*parent may be NULL (top node and proto)*/
	if (parentNode) {
		if (!node->sgprivate->parents) {
			node->sgprivate->parents = (GF_ParentList*)gf_malloc(sizeof(GF_ParentList));
			node->sgprivate->parents->next = NULL;
			node->sgprivate->parents->node = parentNode;
		} else {
			GF_ParentList *item, *nlist = node->sgprivate->parents;
			while (nlist->next) nlist = nlist->next;
			item = (GF_ParentList*)gf_malloc(sizeof(GF_ParentList));
			item->next = NULL;
			item->node = parentNode;
			nlist->next = item;
		}
		if (parentNode->sgprivate->scenegraph != node->sgprivate->scenegraph) {
			gf_list_add(node->sgprivate->scenegraph->exported_nodes, node);
		}
	}
	return GF_OK;
}
GF_Err gf_node_register(GF_Node *node, GF_Node *parentNode)
{
	if (!node) return GF_OK;

	node->sgprivate->num_instances ++;
	 
	if (parentNode) {
		if (!node->sgprivate->parents) {
			node->sgprivate->parents = (GF_ParentList*)gf_malloc(sizeof(GF_ParentList));
			node->sgprivate->parents->next = NULL;
			node->sgprivate->parents->node = parentNode;
		} else {
			GF_ParentList *item, *nlist = node->sgprivate->parents;
			while (nlist->next) nlist = nlist->next;
			item = (GF_ParentList*)gf_malloc(sizeof(GF_ParentList));
			item->next = NULL;
			item->node = parentNode;
			nlist->next = item;
		}
		if (parentNode->sgprivate->scenegraph != node->sgprivate->scenegraph) {
			gf_list_add(node->sgprivate->scenegraph->exported_nodes, node);
		}
	}
	return GF_OK;
}