Careful with this. This starts to fail if your hierarchy gets more than 2 deep. (bug in Python)