ArangoDB is OrientDB done right, but it's a lot younger.
If you're considering using either, you owe it to yourself to investigate whether postgres's Common Table Expressions [0] can do what you want instead. If you can stick with something more mature like postgres, then you'll be saving yourself a lot of pain.
[0] http://www.postgresql.org/docs/9.1/static/queries-with.html
How are you backing this ? I am sure Luca from OrientDB will have some comments.