using std
lca linear time
attempt at missing node handling