func GetLastChild(n Node) Node {
	a := n.GetChildren()
	if len(a) > 0 {
		return a[len(a)-1]
	}
	return nil
}
GetLastChild returns last child of node n
It's implemented as stand-alone function to keep Node interface small
package ast
type ListType int
const (
	ListTypeOrdered ListType = 1 << iota
	ListTypeDefinition
	ListTypeTerm
	ListItemContainsBlock
	ListItemBeginningOfList  
	ListItemEndOfList
)
type CellAlignFlags int
const (
	TableAlignmentLeft CellAlignFlags = 1 << iota
	TableAlignmentRight
	TableAlignmentCenter = (TableAlignmentLeft | TableAlignmentRight)
)
func (a CellAlignFlags) String() string {
	switch a {
	case TableAlignmentLeft:
		return "left"
	case TableAlignmentRight:
		return "right"
	case TableAlignmentCenter:
		return "center"
	default:
		return ""
	}
}
type DocumentMatters int
const (
	DocumentMatterNone DocumentMatters = iota
	DocumentMatterFront
	DocumentMatterMain
	DocumentMatterBack
)
type CitationTypes int
const (
	CitationTypeNone CitationTypes = iota
	CitationTypeSuppressed
	CitationTypeInformative
	CitationTypeNormative
)
type Node interface {
	AsContainer() *Container
	AsLeaf() *Leaf
	GetParent() Node
	SetParent(newParent Node)
	GetChildren() []Node
	SetChildren(newChildren []Node)
}
type Container struct {
	Parent   Node
	Children []Node
	Literal []byte  
	Content []byte  
	*Attribute  
}
func (c *Container) AsContainer() *Container {
	return c
}
func (c *Container) AsLeaf() *Leaf {
	return nil
}
func (c *Container) GetParent() Node {
	return c.Parent
}
func (c *Container) SetParent(newParent Node) {
	c.Parent = newParent
}
func (c *Container) GetChildren() []Node {
	return c.Children
}
func (c *Container) SetChildren(newChildren []Node) {
	c.Children = newChildren
}
type Leaf struct {
	Parent Node
	Literal []byte  
	Content []byte  
	*Attribute  
}
func (l *Leaf) AsContainer() *Container {
	return nil
}
func (l *Leaf) AsLeaf() *Leaf {
	return l
}
func (l *Leaf) GetParent() Node {
	return l.Parent
}
func (l *Leaf) SetParent(newParent Node) {
	l.Parent = newParent
}
func (l *Leaf) GetChildren() []Node {
	return nil
}
func (l *Leaf) SetChildren(newChildren []Node) {
	panic("leaf node cannot have children")
}
type Document struct {
	Container
}
type DocumentMatter struct {
	Container
	Matter DocumentMatters
}
type BlockQuote struct {
	Container
}
type Aside struct {
	Container
}
type List struct {
	Container
	ListFlags       ListType
	Tight           bool    
	BulletChar      byte    
	Delimiter       byte    
	Start           int     
	RefLink         []byte  
	IsFootnotesList bool    
}
type ListItem struct {
	Container
	ListFlags       ListType
	Tight           bool    
	BulletChar      byte    
	Delimiter       byte    
	RefLink         []byte  
	IsFootnotesList bool    
}
type Paragraph struct {
	Container
}
type Math struct {
	Leaf
}
type MathBlock struct {
	Container
}
type Heading struct {
	Container
	Level        int     
	HeadingID    string  
	IsTitleblock bool    
	IsSpecial    bool    
}
type HorizontalRule struct {
	Leaf
}
type Emph struct {
	Container
}
type Strong struct {
	Container
}
type Del struct {
	Container
}
type Link struct {
	Container
	Destination          []byte    
	Title                []byte    
	NoteID               int       
	Footnote             Node      
	DeferredID           []byte    
	AdditionalAttributes []string  
}
type CrossReference struct {
	Container
	Destination []byte  
}
type Citation struct {
	Leaf
	Destination [][]byte         
	Type        []CitationTypes  
	Suffix      [][]byte         
}
type Image struct {
	Container
	Destination []byte  
	Title       []byte  
}
type Text struct {
	Leaf
}
type HTMLBlock struct {
	Leaf
}
type CodeBlock struct {
	Leaf
	IsFenced    bool    
	Info        []byte  
	FenceChar   byte
	FenceLength int
	FenceOffset int
}
type Softbreak struct {
	Leaf
}
type Hardbreak struct {
	Leaf
}
type NonBlockingSpace struct {
	Leaf
}
type Code struct {
	Leaf
}
type HTMLSpan struct {
	Leaf
}
type Table struct {
	Container
}
type TableCell struct {
	Container
	IsHeader bool            
	Align    CellAlignFlags  
	ColSpan  int             
}
type TableHeader struct {
	Container
}
type TableBody struct {
	Container
}
type TableRow struct {
	Container
}
type TableFooter struct {
	Container
}
type Caption struct {
	Container
}
type CaptionFigure struct {
	Container
	HeadingID string  
}
type Callout struct {
	Leaf
	ID []byte  
}
type Index struct {
	Leaf
	Primary bool
	Item    []byte
	Subitem []byte
	ID      string  
}
type Subscript struct {
	Leaf
}
type Superscript struct {
	Leaf
}
type Footnotes struct {
	Container
}
func removeNodeFromArray(a []Node, node Node) []Node {
	n := len(a)
	for i := 0; i < n; i++ {
		if a[i] == node {
			return append(a[:i], a[i+1:]...)
		}
	}
	return nil
}
func AppendChild(parent Node, child Node) {
	RemoveFromTree(child)
	child.SetParent(parent)
	newChildren := append(parent.GetChildren(), child)
	parent.SetChildren(newChildren)
}
func RemoveFromTree(n Node) {
	if n.GetParent() == nil {
		return
	}
	n.SetChildren(nil)
	p := n.GetParent()
	newChildren := removeNodeFromArray(p.GetChildren(), n)
	if newChildren != nil {
		p.SetChildren(newChildren)
	}
}