Add tree.h, tree.c

Signed-off-by: Wadjetz <egor.neon@gmail.com>