Ported from python to java. Recursive is yet to come
Cleanup
Shadows