recursively find dependencies