Fix incorrect root finding for dependency tree