works recursively for nested node objects