Generate dependencies recursively