ahaggar-ast: output the "__end" tag in json to close the node

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
ahaggar-ast: use output_node_end() where needed

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
ahaggar-ast: improve the parent node checks

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>