/* Create a child for a parent. If inherit_children, then the new child will become the new parent of it's parent children  */
static struct callchain_node* create_child(struct callchain_node *parent, bool inherit_children)
/* Create a child for a parent. If inherit_children, then the new child will become the new parent of it's parent children  */
static struct callchain_node* create_child(struct callchain_node *parent, bool inherit_children)
{
	struct callchain_node *new;
	new = malloc(sizeof(*new));
	if (!new) {
		perror("not enough memory to create child for code path tree");
		return NULL;
	}
	new->parent = parent;
	INIT_LIST_HEAD(&new->children);
	INIT_LIST_HEAD(&new->val);
	if (inherit_children) {
		struct callchain_node *next;
		list_splice(&parent->children, &new->children);
		INIT_LIST_HEAD(&parent->children);
		chain_for_each_child(next, new)
			next->parent = new;
	}
	list_add_tail(&new->brothers, &parent->children);
	return new;
}