Allow having multilevel relations in to array

Fix bug with Class1 has_many Class2 and Class2 has_one Class3 relation.

Signed-off-by: Laurent Toussaint <lt.laurent.toussaint@gmail.com>
Add circular reference check for has_many relation

Signed-off-by: Laurent Toussaint <lt.laurent.toussaint@gmail.com>
Merge pull request #359 from ltoussaint/toarray_multilevel

Fix on to_array with multi level relations