modified find,nodeDistRoot function