Learning the structure of any Hamiltonian from minimal assumptions