Added initial version of function which simplify afs ast-tree