Okay, the first problem was as follows. Space Exploration Postprocess expects to get a simple version of technology ingredient codes, while my science packs are inserted in an expanded one. This might cause Space Exploration Postprocess to be incompatible with any mods that add liquid science, but since it is a complete overhaul, this is not going to be a problem, I guess.
I changed the code to adding sciences, and now Space Exploration Postprocess exits with stack overflow. Seems that it encountered a cyclic dependency, which would be a bit of work to debug, so don't expect the fix soon.
UPD: my mod returns a tech tree without any cyclic dependencies; my code is working correctly, and even Space Exploration Postprocess code for pruning the tech tree is working correctly if put inside my mod. I assume there is some change (either inside of Postprocess directly, or in some other dependency of Space Exploration along the way) that breaks the tree.